git fetch并结帐FETCH_HEAD后会做什么? [英] What does git fetch followed by checkout FETCH_HEAD do?

查看:100
本文介绍了git fetch并结帐FETCH_HEAD后会做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下命令做什么:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆