本文介绍了Git 中的 FETCH_HEAD 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git pull --help 说:

在默认模式下,git pullgit fetch 后跟 git merge FETCH_HEAD 的简写.

这个 FETCH_HEAD 是什么以及在 git pull 期间实际合并了什么?

What is this FETCH_HEAD and what is actually merged during git pull?

推荐答案

FETCH_HEAD 是一个短期引用,用于跟踪刚刚从远程存储库中获取的内容.git pull 首先调用git fetch,一般情况下是从远程获取一个分支;FETCH_HEAD 指向这个分支的顶端(它存储提交的 SHA1,就像分支一样).git pull 然后调用 git merge,将 FETCH_HEAD 合并到当前分支中.

FETCH_HEAD is a short-lived ref, to keep track of what has just been fetched from the remote repository. git pull first invokes git fetch, in normal cases fetching a branch from the remote; FETCH_HEAD points to the tip of this branch (it stores the SHA1 of the commit, just as branches do). git pull then invokes git merge, merging FETCH_HEAD into the current branch.

结果正是您所期望的:适当远程分支尖端的提交合并到当前分支尖端的提交中.

The result is exactly what you'd expect: the commit at the tip of the appropriate remote branch is merged into the commit at the tip of your current branch.

这有点像不带参数执行git fetch(或git remote update),更新所有远程分支,然后运行git merge origin/<branch>,但在内部使用 FETCH_HEAD 来引用获取的任何单个引用,而不是需要命名.

This is a bit like doing git fetch without arguments (or git remote update), updating all your remote branches, then running git merge origin/<branch>, but using FETCH_HEAD internally instead to refer to whatever single ref was fetched, instead of needing to name things.

这篇关于Git 中的 FETCH_HEAD 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 01:54
查看更多