push, pull & fetch

Syncing with the Remote

CommandDirectionDoes
git pushlocal → remoteUpload your commits
git fetchremote → localDownload commits, don't merge
git pullremote → localFetch and merge into your branch
$ git push origin main
$ git pull            # = git fetch + git merge
Analogy: fetch is checking the mailbox (you see what arrived). pull is checking the mailbox and filing everything into your drawers (fetch + merge). push is mailing your letters out.
Warning: git pull can trigger a merge conflict if the remote changed lines you also changed. Commit or stash your work before pulling so you're never merging on top of a messy tree.

First push of a new branch needs the upstream set:

$ git push -u origin feature-login   # -u links local ↔ remote branch
$ git push                           # afterwards, just this