Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git error: refname 'HEAD' is ambiguous

Tags:

git

I'm fairly new to git. Currently I try to follow this tutorial to overlay the icon of my app with branch name and version: http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/

I get however an error when executing

git rev-parse --abbrev-ref HEAD
warning: refname 'HEAD' is ambiguous.
error: refname 'HEAD' is ambiguous

googling brought up some results suggesting that this happens when there is a branch named 'HEAD' - but I don't think that's the case. At least in the online repository on bitbucket I don't see any branch labeled 'HEAD' and querying it through the terminal yields:

git branch -r
origin/#224-Push-notifications
origin/1.0.2
origin/HEAD -> origin/master
origin/app-forced-update
origin/master
origin/milestone6
origin/staging


git branch
* #224-Push-notifications
1.0.2
HEAD
master
milestone3
milestone4
milestone5
milestone6

not sure why on the remote HEAD there is a -> while on the local HEAD there is none. maybe that's the problem?

also, searching for HEAD in the .git folder yields

find .git -name HEAD
.git/HEAD
.git/logs/HEAD
.git/logs/refs/heads/HEAD
.git/logs/refs/remotes/origin/HEAD
.git/refs/heads/HEAD
.git/refs/remotes/origin/HEAD

anyone understands what's the issue and how I can cleanly resolve it?

like image 254
matthias_buehlmann Avatar asked Jan 17 '26 18:01

matthias_buehlmann


1 Answers

You've got a local branch called HEAD, so git doesn't know whether you're referring to that or the HEAD, which is the latest commit in the current branch. It's not a good idea to name a branch HEAD, so you should delete it: git branch -D HEAD. This'll fix the rev-parse error.

origin/HEAD -> origin/master in the remote branches is a remote-specific thing that means the master branch will be checked out when you clone from the remote.

like image 101
desbo Avatar answered Jan 19 '26 19:01

desbo