Interview Prep/Git & GitHub/Commits, branches and tags

How do upstream (tracking) branches work?

IntermediateConceptCommits, branches and tags
Answer

A local branch can record branch.<name>.remote and branch.<name>.merge, which makes bare git pull, git push and the ahead/behind counts in git status work. Set it with -u on first push or --set-upstream-to. With push.autoSetupRemote true the first git push does it automatically.

git push -u origin feature/x
git branch -vv
All Git & GitHub questions Roadmap: Git & GitHub

More on Commits, branches and tags