After a git commit
, I have two options:
git push
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.
Git Push Origin pushes all the branches to the main branch. Git Push Origin Master pushes your master branch to the origin.
Git push origin is usually used only where there are multiple remote repositories and you want to specify which remote repository should be used for the push. For a git push origin command: git push command updates remote references using local references by sending objects necessary to complete the given references.
The term "git origin master" is used in the context of a remote repository. It is used to deal with the remote repository. The term origin comes from where repository original situated and master stands for the main branch. Let's understand both of these terms in detail.
Master: This is a branch name where we first initiate git and then we use to make commits. And the changes in the master can pull/push into a remote. origin/master: This is a remote branch, which has a local branch named master on a remote named origin.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With