remote-tracking branch
A local, read-only record of where a branch on a remote pointed the last time you talked to it, such as origin/main.
In more detail
It lives under .git/refs/remotes and moves only when you fetch, pull or push, never when you commit. git status compares your branch with it to say you are ahead or behind, which is why it only notices new remote work after a fetch. git branch -r lists them.
Example
git log --oneline origin/mainRelated terms
- remote — A short name saved in a repository's config that stands for another repository's location, a URL or a path, so you can fetch from and push to it.
- upstream branch — The remote branch your local branch is linked to, which git push, git pull and git status use when you do not name one.
- git fetch — The command that downloads new commits and refs from a remote and updates your remote-tracking branches, without changing your own branches or files.
- ref — A Git name that points at a commit, such as a branch (refs/heads/main) or a tag (refs/tags/v1.0).
Taught in
- What A Remote Actually Is — Advanced Git Internals & Distributed Workflows
- Fetch Is Not Pull — Advanced Git Internals & Distributed Workflows