我不明白在某些情况下创建 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/