Refname is ambiguous

I can get this behavior by giving a branch a name that matches the SHA1 prefix of a commit.

$ git rev-list @ | egrep '^[0-9]{4}'
$ git branch 7802
$ git branch 9999
$ git checkout 7802
warning: refname '7802' is ambiguous.
Switched to branch '7802'
$ git checkout 9999
Switched to branch '9999'

Since object id prefixes at least four digits long are legitimate ways of referring to objects, making a ref name that’s also a four-or-more-long hex string is likely to produce this kind of ambiguity. So, don’t do that. If you want to number something, include a type marker, like bugfix/1601 or something.

Leave a Comment