Tracking Branches
The relationship between main and origin/main.
A tracking branch is a local branch that has a registered upstream counterpart. Git uses this relationship to compute ahead/behind counts, power git pull and git push with no arguments, and tell you exactly how your work relates to the remote.
The Four Possible States
Toggle between states to see how the graph, git status, and git branch -vv output change — and what the tracking config in .git/config looks like.
.git/refs/remotes/origin/ recording where the remote's branch was the last time you fetched.What “tracking” actually means
origin/main is not a live view of the remote — it is a local ref that records where origin's main was the last time you fetched. It lives in .git/refs/remotes/origin/main and is updated only by fetch, pull, or push.
The tracking relationship is stored in .git/config under [branch "main"]. Two keys matter: remote (which remote to talk to) and merge (which remote ref to integrate).
With tracking set up, git pull and git push know what to do with no arguments. Without it, you must be explicit: git push origin main.
Setting up tracking
Tracking is set automatically when you clone (for the default branch) or when you push with -u. You can also set it explicitly at any time.