Lessons · Git · sending your commits
Sending commits up
git push sends your commits to a branch on the remote. The first time, -u sets the upstream so plain git push and git pull know where to go.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
Until you push, your work exists on one machine. Push is also how a branch becomes visible for a pull request.
How to think about it
Commit first: only commits travel. Push with -u the first time for a new branch, then plain push. If the push is refused, someone else pushed first: fetch, integrate, push again.
Worked example
git push -u origin mainSends your commits and remembers origin/main as the upstream.
git pushFrom then on, the short form knows where to go.
git push -u origin featureA branch that has never been pushed: name it the first time.
Your turn
Push a new branch and remember where it goes.
git push origin feature
Try it in a real repository
The trap
Only commits travel. Uncommitted edits stay on your machine, and a push with nothing new says Everything up-to-date while your work sits unsaved.