Can someone please explain the difference, if it exists, between both commands:
git push --set-upstream origin master
git push -u origin master
I tested both and both push but I am unable to see the difference between them.
Those are the exact same command. -u
and --set-upstream
are different names for the same flag.
Quoting the docs for git push
:
-u
,--set-upstream
For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-lessgit-pull
and other commands. For more information, seebranch.<name>.merge
ingit-config
.
Do note that setting an upstream for the master
branch is entirely optional. You can omit -u
/--set-upstream
entirely if you don't plan on using the argument-less variants of git push
/git pull
/etc. See What is a git upstream and Definition of "downstream" and "upstream" for more information on what setting an "upstream" means in git.