Fixing an ‘Ambiguous Head’ in Git

Git is great, but sometimes I feel you can shoot yourself in the foot with it when you don’t even know you’re holding a gun. If you are getting this message from git:

warning: refname 'HEAD' is ambiguous.

Try running git show-ref. In my case I had a local tag I created by accident named ‘head’. That’s what confusing command line options get you I suppose.



Filed under git

4 responses to “Fixing an ‘Ambiguous Head’ in Git

  1. Nick

    That’s all well and good, but how do you fix it?

  2. Actually, that will delete a branch named HEAD. You probably want…

    `git tag –delete HEAD`

  3. Tony Camuso

    Thank you for the help!
    I found the errant tag with this command.
    $ git show-ref | grep HEAD
    cb2e8bbf916877af21e4b4f83c1173c404d78094 refs/tags/HEAD

    And the following command fixed the problem
    $ git tag -d HEAD
    Deleted tag ‘HEAD’ (was cb2e8bbf91687)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s