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?
-
See also stackoverflow.com/a/17096880/6309VonC– VonC2014-06-04 04:54:58 +00:00Commented Jun 4, 2014 at 4:54
Add a comment
|
1 Answer
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