git pull origin master 和 git pull origin/master 的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2883840/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 08:25:54  来源:igfitidea点击:

Differences between git pull origin master & git pull origin/master

gitversion-control

提问by Rachel

What is the difference between git pull origin masterand git pull origin/master?

git pull origin master和 和有git pull origin/master什么区别?

回答by Jakob Borg

git pull origin masterwill pull changes from the originremote, masterbranch and merge them to the local checked-out branch.

git pull origin master将从origin远程master分支中提取更改并将它们合并到本地检出分支。

git pull origin/masterwill pull changes from the locally stored branch origin/masterand merge that to the local checked-out branch. The origin/masterbranch is essentially a "cached copy" of what was last pulled from origin, which is why it's called a remote branch in git parlance. This might be somewhat confusing.

git pull origin/master将从本地存储的分支中提取更改origin/master并将其合并到本地签出的分支。该origin/master分支本质上是上次从 中提取的内容的“缓存副本” origin,这就是为什么在 git 术语中将其称为远程分支的原因。这可能有点令人困惑。

You can see what branches are available with git branchand git branch -rto see the "remote branches".

您可以查看哪些分支可用git branchgit branch -r查看“远程分支”。

回答by Dhruvil Shah

git pull origin masterwill fetch all the changes from the remote's master branch and will merge it into your local.We generally don't use git pull origin/master.We can do the same thing by git merge origin/master.It will merge all the changes from "cached copy" of origin's master branch into your local branch.In my case git pull origin/masteris throwing the error.

git pull origin master将从远程的 master 分支中获取所有更改并将其合并到您的本地。我们通常不使用 git pull origin/master。我们可以通过 git pull origin/master 做同样的事情。git merge origin/master它将合并来自“缓存副本” origin 的 master 分支到你的本地分支。在我的情况下git pull origin/master是抛出错误。

回答by user33276346

git pull= git fetch+ git merge origin/branch

git pull= git fetch+git merge origin/branch

git pulland git pull origin branchonly differ in that the latter will only "update" origin/branch and not all origin/* as git pulldoes.

git pullgit pull origin branch唯一的区别,后者只会“更新”的由来/支,而不是所有的原产地/ *为git pull一样。

git pull origin/branchwill just not work because it's trying to do a git fetch origin/branchwhich is invalid.

git pull origin/branch将无法正常工作,因为它正在尝试执行git fetch origin/branch无效的操作。

Question related: git fetch + git merge origin/master vs git pull origin/master

相关问题:git fetch + git merge origin/master vs git pull origin/master