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?

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.