git pull origin master和git pull origin/master之间的区别是什么?


当前回答

Git pull origin master将从远程的主分支获取所有更改,并将其合并到本地。我们一般不使用git拉origin/master。我们可以用git merge origin/master来做同样的事情。它会将所有的更改从“缓存副本”的原始主分支合并到您的本地分支。在我的情况下,git拉origin/master抛出错误:

fatal: 'origin/master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

其他回答

git pull = git fetch + git merge origin/branch

Git pull和Git pull origin branch的区别只在于后者只会“更新”origin/branch,而不会像Git pull那样“更新”所有的origin/*。

Git pull origin/branch将无法工作,因为它试图做一个无效的Git fetch origin/branch。

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

Git pull origin master将从远程的主分支获取所有更改,并将其合并到本地。我们一般不使用git拉origin/master。我们可以用git merge origin/master来做同样的事情。它会将所有的更改从“缓存副本”的原始主分支合并到您的本地分支。在我的情况下,git拉origin/master抛出错误:

fatal: 'origin/master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Git pull origin master将从origin remote, master分支中提取更改,并将它们合并到本地签出分支。

Git pull origin/master将从本地存储的分支origin/master中提取更改,并将其合并到本地签出的分支中。源/主分支本质上是一个“缓存副本”的最后从原点,这就是为什么它被称为一个远程分支在git的说法。这可能有点令人困惑。

你可以通过git branch和git branch -r来查看“远程分支”。