Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upstream in git and use of -u flags in push

Tags:

git

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 ?

like image 303
Hardik Joshi Avatar asked Jun 24 '12 04:06

Hardik Joshi


People also ask

What is upstream flag in git?

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 .

What is flag in git push?

The --force flag allows you to order Git to do it anyway. When you change history, or when you want to push changes that are inconsistent with the remote branch, you can use push --force .

Does git push push to upstream?

When you set your upstream (or tracking) branches, you can simply execute pulls and pushes without having to specify the target branch. Git automatically knows that it has to fetch the new commits to the remote tracking branch. Similarly, Git already knows that it has to push new commits to the upstream branch.

What does push to upstream mean in git?

pushing " upstream " means that your current branch B has remote/B has its upstream branch. Ie: branch. B. merge is set, when your are pushing the " upstream " branch. Ie: when pulling to B , git knows what branch to pull (as well as which remote repo: branch.B.remote )


1 Answers

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

like image 114
Todd A. Jacobs Avatar answered Sep 29 '22 21:09

Todd A. Jacobs