1

I've been using git push -u origin branch for a while now. but seeing my workmates manage to push a new branch using git push origin branch without the switch u got me thinking, what are there main difference? are there any at all?

Viscocent
  • 1,924
  • 1
  • 16
  • 25

1 Answers1

4

git help push will tell you

   -u, --set-upstream
       For every branch that is up to date or successfully pushed, add
       upstream (tracking) reference, used by argument-less git-pull(1)
       and other commands. For more information, see branch.<name>.merge
       in git-config(1).

Meaning if you run git push -u some_repo some_branch then after the push some_repo/some_branch is set as the upstream for the subsequent pulls.

So the next time you have some_branch checked out locally and you run git pull it will automatically try to pull from some_repo/some_branch

Spundun
  • 3,808
  • 2
  • 21
  • 34