git - 创建 FETCH_HEAD 背后的逻辑

标签 git

我不明白在某些情况下创建 FETCH_HEAD 背后的逻辑 - 例如:

$ git --version
git version 1.7.2.5

$ git fetch aarep       
From ../aa
 * [new branch]      master     -> aarep/master
 * [new branch]      skin       -> aarep/skin
## Fair enough, creating FETCH_HEADs here wouldn't help


$ git fetch aarep master
From ../aa
 * branch            master     -> FETCH_HEAD
## Instead of creating a remote tracker, git creates a FETCH_HEAD. No problem.

$ git fetch aarep master skin
From ../aa
 * branch            master     -> FETCH_HEAD
 * branch            skin       -> FETCH_HEAD
## What's the point of creating FETCH_HEADs here - only one would survive ?!

最佳答案

在上一个示例之后查看 FETCH_HEAD 的内容。两个 refs 都在那里,可能是这样的:

b0d66b5110faaeb395610ba43b6eb70a18ab5e25        branch 'master' of git://git.kernel.org/pub/scm/git/git
a9004c5cb2204cf950debab328e86de5eefb9da4        branch 'next' of git://git.kernel.org/pub/scm/git/git

它没有被覆盖。

值得一提的是,这是在 git-pull 中使用此功能,它是作为 shell 脚本实现的:

merge_head=$(sed -e '/  not-for-merge   /d' \
    -e 's/  .*//' "$GIT_DIR"/FETCH_HEAD | \
    tr '\012' ' ')

关于git - 创建 FETCH_HEAD 背后的逻辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9336950/

相关文章:

git - 如何保持 GIT 仓库同步

git - 如何在 git 别名中使用 bash 函数?

git - 如何让 travis-ci 使用本地 git 分支而不是特定的提交?

linux - GitHub 帮助 - 将文件夹推送到存储库

windows - 如何从 Git 存储库中删除特定文件名的所有实例?

python - .ptvs 可以安全地被 git 忽略吗?

git - 无法从 IntellIJ 中的远程存储库读取

git - 具有多个分支的 Git 存储库模板的最佳方法?

Git:当我没有 merge 它们时,一个功能分支出现在主分支中

git - AWS 'eb deploy' 始终压缩所有文件