What does git push -u (set upstream) do, and how does it change future push/pull behavior?

Last updated 6 July 2026

git push -u (short for --set-upstream) pushes the branch and records a tracking link between your local branch and the remote branch, so future git push and git pull need no arguments.

  • What it sets:

    • Configures the branch's upstream (tracking) reference, e.g. origin/feature.

    • Stored in .git/config under the branch's remote and merge keys.

  • Effect on later commands:

    • Bare git push and git pull now know the target automatically.

    • git status can report ahead/behind counts vs the upstream.

  • You only need -u once per branch; after that the link persists.

[lang:bash] git push -u origin feature # first push, sets tracking git push # later: no args needed git pull # pulls from origin/feature

  • https://git-scm.com/docs/git-push
  • https://adamj.eu/tech/2022/10/31/git-how-to-automatically-create-upstream-branches/
  • https://gitlab.com/git-scm/git/-/blob/HEAD/Documentation/RelNotes/2.16.0.adoc
  • https://www.git-tower.com/learn/git/faq/set-upstream
  • https://www.warp.dev/terminus/understanding-git-push-origin
  • https://forum.freecodecamp.org/t/what-does-u-mean-in-this/635014
All Git interview questions