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 ?
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 .
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 .
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.
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 )
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
.
http://git-scm.com/book/en/Git-Branching-Remote-Branches#Tracking-Branches
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With