Search code examples
gitgithubgit-push

What is the difference between "git push" and "git push origin master"?


After a git commit, I have two options:

  1. git push
  2. git push origin master

My intent is to push my changes in my local repo to GitHub master branch. In what circumstances do they make a difference?

(Also, what does "origin" here mean?)


[UPDATE]:

I think this is not a duplicate question with this post, because, on the mentioned duplicate post, the question about git push origin and in this question is about git push only.


Solution

  • git push assumes that you already have a remote repository defined for that branch. In this case, the default remote origin is used.

    git push origin master indicates that you are pushing to a specific remote, in this case, origin.

    This would only matter if you created multiple remote repositories in your code base. If you're only committing to one remote repository (in this case, just your GitHub repository), then there isn't any difference between the two.