The logic behind the creation of FETCH_HEADs


I don't understand the logic behind creating FETCH_HEADs in some cases - example:

$ git --version
git version

$ 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 ?!

Have a look at the contents of FETCH_HEAD after your last example. Both refs are there, perhaps something like:

b0d66b5110faaeb395610ba43b6eb70a18ab5e25        branch 'master' of git://
a9004c5cb2204cf950debab328e86de5eefb9da4        branch 'next' of git://

It's not overwritten.

For what it's worth, here's a use of this functionality in git-pull, which is implemented as a shell script:

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