Git & GitHub
/Beginner
git push
Definition
Uploads local repository content (commits and branches) to a remote repository.
Explain Like I'm New
The upload button. You finished your feature, you made your commits locally, but your boss can't see them yet. `git push` takes your local timeline and sends it up to GitHub for everyone to see.
Real World Example
You finish your work for the day, commit it, and run `git push origin main` so the server has a backup in case your laptop breaks overnight.
Common Use Cases
- •Sharing code
- •Backing up code to the cloud
- •Publishing websites
Architecture & Flow
Terminal Output
bash / terminal
# 1. Save your work locally FIRST
$ git commit -am "Finish the homepage"
# 2. Upload that commit to the 'origin' server, on the 'main' branch
$ git push origin main
# 3. Create a brand new branch, and push it to the server for the first time
# (-u sets the upstream link so Git remembers where to push next time)
$ git checkout -b my-new-feature
$ git push -u origin my-new-feature
# 4. In the future, you can just type:
$ git push
Interview Questions
basic
- If you edit a file, can you just run `git push` immediately to save it to GitHub?
intermediate
- What does the `-u` flag do in `git push -u origin main`?