Explain the difference between an "Upstream" branch and a "Tracking" branch.

Last updated 6 July 2026

  • Same relationship, two angles: the tracking branch is your local branch (e.g. main), and the upstream is the remote branch it follows (e.g. origin/main).

  • Set it with git push -u origin main or git branch --set-upstream-to=origin/main.

  • It enables bare git pull/git push without arguments and the ahead/behind status.

  • https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches
  • https://git-scm.com/docs/git-branch/2.38.0
  • https://docs.rockylinux.org/10/gemstones/git/tracking_and_nontracking_branch/
  • https://graphite.com/guides/git-remote-branches
All Git interview questions