Skip to main content

git: fatal: invalid reference: foo

Today, git barfed with:

$ git bisect start
fatal: invalid reference: b
Huh? What is "reference b", what is git trying to tell me here? Pondering on this a bit more I remembered that I once created a branch named "b". But that was quite some time ago and git branch -a did not show the branch either. And bit reset --hard did not help. Grrr. There was a patch floating around dealing with this issue, but AFAICT it "only" made the error message more verbose. So I felt lucky and did:
$ egrep -rl 'b$' .git | grep -v objects
And indeed, there were those old BISECT_* files, which must have been from an old git bisect run. Removing the .git/BISECT_* did the trick and now we're in the middle of yet another bisect - oh jolly :-\