git 类似于 "hg pull"

git's analog of "hg pull"

在 mercurial 中,当我 运行 hg pull 我将从远程存储库获取所有更改,但此命令不会更新本地工作目录。当我 运行 hg update 此命令将应用工作目录中的更改。

在 git 中,当我 运行 git pull 时,命令将获取并应用工作目录中的更改。

所以我的问题是如何从远程存储库中提取更改(在 git 中)但不应用它们?

我相信您正在寻找的命令是 git fetch。来自 documentation:

Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated.

Git fetch 从远程加载所有更改,而不更新实际的本地分支。在上面的简介中,"remote-tracking" 分支是跟踪远程存储库中状态的本地分支(是的,这很混乱),但它们不是您的本地分支。

假设你在分支master,那么:

git fetch origin          # updates origin/master
git merge origin/master   # updates your local master

git pull origin master 等同于做 git fetch 然后 git merge.