Hardik Joshi
Hardik Joshi

Reputation: 849

upstream in git and use of -u flags in push

what is use of -u flag while pushing commits to some git repo? I mean what is differnece between git push origin master and git push -u origin master ? Can anyone please describe its usage ?

Upvotes: 41

Views: 13067

Answers (1)

Todd A. Jacobs
Todd A. Jacobs

Reputation: 84373

The git(1) manual page says:

-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..merge in git-config(1).

Basically, you use this flag when you want to set origin as the upstream remote for a branch. This is needed if you don't want to manually specify the remote every time you use git pull.

See Also

http://git-scm.com/book/en/Git-Branching-Remote-Branches#Tracking-Branches

Upvotes: 36

Related Questions