Search code examples
gitgit-push

What is the exact difference between "git push -u" and "git push --set-upstream"?


Scenario 1:
When we create a remote repo and then try to push to GitHub, we must do git push -u repoName branchName.

Scenario 2: When we create a new branch locally and then we push to GitHub, we must do git push --set-upstream repoName BranchName.

So, my question is: Is there any difference between git push -u and git push --set-upstream?

If yes, what is exactly the difference?


Solution

  • As mentioned in the comments, there is NO difference between git push -u and git push --set-upstream. Git options -u and --set-upstream are the same.

    Please check git push -u documentation or just type git push --help in the command line for more information.