git pull 可以用于更新上游的存储库吗

Can git pull be used to update repository with an upstream

来自 What is the difference between 'git pull' and 'git fetch'?,

如果 git pullgit fetch 后跟 git merge 的组合,git pull upstream master 是否可以用于 获取和合并 上游在分叉存储库克隆中的更改。

简答NO.您必须将上游仓库添加为另一个远程仓库。当然,您可以将其命名为 upstream。然后 运行 git pull upstream master

您可以这样添加遥控器:

git remote add upstream <url-of-upstream-repo>

正如@VonC 在他的 answer -

中所说的那样

您必须将原始存储库(您分叉的那个)添加为远程。

来自GitHub fork man page

Once the clone is complete your repo will have a remote named “origin” that points to your fork on GitHub.
Don’t let the name confuse you, this does not point to the original repo you forked from. To help you keep track of that repo we will add another remote named “upstream”:

$ cd github-services
$ git remote add upstream git://github.com/pjhyett/github-services.git
$ git fetch upstream

# then: (like "git pull" which is fetch + merge)
$ git merge upstream/master master

# or, better, replay your local work on top of the fetched branch
# like a "git pull --rebase"
$ git rebase upstream/master

从远程分支获取后,您仍然需要合并提交。

在这里你可以做的是替换

$ git fetch upstream

$ git pull upstream master

因为 git pull 本质上是 git fetch + git merge 正如你所说。