git fetch并结帐FETCH_HEAD后会做什么? [英] What does git fetch followed by checkout FETCH_HEAD do?
问题描述
以下命令做什么:
git fetch <remote> <branch> && git checkout FETCH_HEAD
我只有一个本地分支(master
),并且执行上述命令.我应该对本地存储库进行哪些更改,以及如何验证(查看)它们?
I have only one local branch (master
) and I execute the above command. What changes to my local repository should I expect and how can I verify (see) them?
推荐答案
您可能知道命令的第一部分将执行的操作. git fetch <remote> <some_branch>
将更新您指定的分支的本地跟踪分支.但这不会更改计算机上实际的本地对应some_branch
.
You are probably aware of what the first part of your command will do. git fetch <remote> <some_branch>
will update the local tracking branch of the branch you specify. But this will not alter the actual local corresponding some_branch
on your machine.
当您执行git fetch
时,Git有一个称为FETCH_HEAD
的特殊引用,该引用指向刚刚获取的分支.在这种情况下,它将指向remote/some_branch
,因为这是刚刚获取的分支.通过做
When you do a git fetch
, Git has a special ref called FETCH_HEAD
which points to the branch which was just fetched. In this case, it would point to remote/some_branch
, since this is the branch which was just fetched. By doing
git checkout FETCH_HEAD
您将在分离的HEAD状态下签出origin/some_branch
.这可能不是您想要的,但是无论如何,您的复合命令实际上不会更新本地some_branch
.为此,您需要执行一个额外的git merge
步骤,或者仅从some_branch
中执行一个git pull
.
you would be checking out origin/some_branch
in a detached HEAD state. This may or not may not be what you intend, but in any case, your compound command would not actually update the local some_branch
. To do that, you would need an additional git merge
step, or to just do a git pull
from some_branch
.
这篇关于git fetch并结帐FETCH_HEAD后会做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!