【发布时间】:2019-11-17 20:13:57
【问题描述】:
我很乐意为这个问题写一个更准确的主题,但我现在无法更好地表达它。
基本上,假设您有一个仓库,其中有多个分支,例如“master”和“mybranch”。
所以,假设你在 master 上:
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
然后你在这里做git pull;为master 分支和mybranch 检索新提交。由于您已经在分支 master 中,master 的 HEAD 会由 git 自动更新为最新收到的提交。
现在,假设您使用结帐更改分支:
$ git checkout mybranch
Switched to branch 'mybranch'
Your branch is behind 'origin/mybranch' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
现在这让我感到困惑 - 在之前的 pull 中,(显然)所有最新的提交 - 包括 mybranch 中的提交 - 都已被检索;否则我的本地 git 不会“知道”我的本地分支“落后于 ... 2 次提交”。
所以我的问题是:当我们已经下载了mybranch 的那些新提交时,为什么我需要再次执行“git pull”,不必要地往返服务器?没有“git update-head”或一些命令,可以在本地执行,无需往返服务器?
【问题讨论】: