What is the difference between $ git push -u origin master and $ git push origin master?

3

What is the difference in using the -u flag when I do $git push to upload my local repository to a remote one? I see they do the same, both $git push origin master as $git push -u origin master I read this manual but I have not could understand the concept well

    
asked by Juan Diego Silva 21.10.2017 в 23:05
source

1 answer

2

The u means upstream and it refers to the main remote repository to which you will do pull and push , this option is used only once.

When you have more than one remote repository you can use this option to configure one of them as the main one ... assuming you have a repo in BitBucket (bitbucket), another in GitHub (origin) and another in GitLab (gitlab) and you would like to use GitHub (origin) as the main one, you would have to do git push -u origin <branch> and the following times when doing only git push will do it to GitHub without having to specify the repository but for the other two if you would have to do it, eg. git push bitbucket <branch> or git push gitlab <branch> . Even if you have only one repository and you want to avoid writing git push origin <branch> you can use this option and only do git push the following times.

This option is also known as "argument-less git-pull / push (git-pull / push without arguments)"

    
answered by 22.10.2017 / 01:44
source