Skip to content
Remotes

Tracking branches

`origin/main` is not the remote. It is your memory of it.

`origin/main` is a remote-tracking branch: a local record of where `main` was on the remote the last time you looked. It changes when you fetch, and at no other time.

Everything confusing about "ahead 2, behind 1" follows from that. Git is comparing your branch with your last snapshot of theirs, not with the remote as it is now.

`git fetch` updates that snapshot and touches nothing else, which is why it is always safe. `git pull` is a fetch followed by a merge or a rebase — the second half is the part that can surprise you.

Commands in this lesson

git remote
List or configure the repositories this one can exchange objects with
git fetch
Update your record of a remote without touching your branches
git push
Send commits to a remote, if doing so would not remove any
No account, no backend. Everything you do stays in this browser.liter8.sh