“git push”和“git push origin master”有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29858663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between "git push" and "git push origin master"?
提问by Ka-Wa Yip
After a git commit
, I have two options:
在 a 之后git commit
,我有两个选择:
git push
git push origin master
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?
我的目的是将我在本地存储库中的更改推送到 GitHub 主分支。他们在什么情况下会有所作为?
(Also, what does "origin" here mean?)
(另外,这里的“起源”是什么意思?)
[UPDATE]:
[更新]:
I think this is not a duplicate questionwith 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
和在这个问题中的问题只是关于git push
。
回答by Makoto
git push
assumes that you already have a remote repositorydefined for that branch. In this case, the default remote origin
is used.
git push
假设您已经为该分支定义了一个远程存储库。在这种情况下,将使用默认遥控器origin
。
git push origin master
indicates that you are pushing to a specificremote, in this case, origin
.
git push origin master
表示您正在推送到特定的遥控器,在本例中为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, justyour GitHub repository), then there isn't any difference between the two.
这仅在您在代码库中创建多个远程存储库时才重要。如果您只提交到一个远程存储库(在这种情况下,只是您的 GitHub 存储库),那么两者之间没有任何区别。