I'm posting a self-answer because I know some of my colleagues will be googling this soon. We sometimes need to distribute bundle files which are baselined on master and hence only contain the particular branches explicitly included when it was created. For example, the distributor does:
git bundle create ../file.gitbundle master..feature/aunit_reporters
The problem is, after receiving a bundle file, doing git pull ../file.gitbundle gives:
fatal: Couldn't find remote ref HEAD
I've verified the bundle file should be applicable, by:
git bundle verify ../file.gitbundle
The bundle contains this ref:
4f969119b208b71f4893222810600862 refs/heads/feature/aunit_reporters
The bundle requires this ref:
fd9801b79b56f5dd55ab1e6500f16daf
and git show fd9801b79b56f5dd55ab1e6500f16daf correctly displays the commit needed, instead of giving fatal: ambiguous argument '[commit-hash]': unknown revision or path not in the working tree, which would signal that I don't have the necessary baseline commit.
The second parameter to
git pull [remote]is optional and defaults to 'HEAD'. This is the case whether you are using a bundle file or not, but normally real git repositories (local and hosted) have a HEAD pointing somewhere, so the default works. Partial bundle files may not have this; the distributor should really have added HEAD, to allow a regular pull:(unfortunately you have to specify the branchname twice now, otherwise you get a detached HEAD repository, which is equally if not more confusing to the recipient)
The solution is to specify the second parameter as one of the branches that is output by the
git bundle verifycommand, in your case 'feature/aunit_reporters'.