Can someone please explain the difference, if it exists, between both commands:
git push --set-upstream origin mastergit 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-pulland other commands. For more information, seebranch.<name>.mergeingit-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.
There is no difference between ‘git push –set-upstream origin master’ and ‘git push –u origin master’. The ‘-u’ option is a shorthand for ‘—set-upstream’. Both commands will accomplish the task of pushing changes to the remote repository and setting up tracking for the specified branch. The use of -u is just a shorter and more convenient way to specify --set-upstream.
git help <cmd>in a terminal. For example, the main answer is an excerpt fromgit help push. This is the goto method to check if a command supports a specific flag, or how it should be worded, or ...