What is the difference in using the flag -u
when I $git push
push my local repository to a remote one? I see that they do the same thing, as much
$git push origin master
as $git push -u origin master
I have read this manual but I have not been able to understand the concept well
The u stands for upstream and refers to the main remote repository you will do
pull
ypush
, this option is used only once.When you have more than one remote repository you can use this option to set one of them as the main one... assuming you have one repo on BitBucket (bitbucket), one on GitHub (origin) and one on GitLab (gitlab) and you would like to use GitHub (origin) as main, you would have to do
git push -u origin <branch>
and the following times when doing it will onlygit push
do it to GitHub without having to specify the repository but for the other two you would have to do it, eg.git push bitbucket <branch>
orgit push gitlab <branch>
. The same if you have a single repository and you want to avoid writing,git push origin <branch>
you can use this option and only dogit push
the following times.This option is also known as "argument-less git-pull/push (git-pull/push without arguments)"