{"thread":{"id":"40019","subject":"[Bug] incomplete defence agains creating a branch named HEAD","startedAt":"2015-08-05T15:46:17Z","lastAt":"2015-08-05T15:46:17Z","messageCount":1,"participants":["Dennis Kaarsemaker"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"267516","messageId":"1438789577.17587.7.camel@kaarsemaker.net","threadId":"40019","inReplyTo":null,"subject":"[Bug] incomplete defence agains creating a branch named HEAD","fromName":"Dennis Kaarsemaker","fromEmail":"dennis@kaarsemaker.net","sentAt":"2015-08-05T15:46:17Z","receivedAt":"2015-08-05T15:46:17Z","isPatch":false,"sender":{"key":"dennis@kaarsemaker.net","avatar":"https://avatars.githubusercontent.com/u/200649?v=4"},"body":"So git branch doesn't like to create a branch named HEAD\n\n$ git branch HEAD\nfatal: it does not make sense to create 'HEAD' manually\n\nBut, you can trick it into doing so anyway:\n\n$ git branch @\n$ git branch -a\n  HEAD\n* master\n\nAt which point git status becomes a bit confused:\n\n$ git status\nwarning: refname 'HEAD' is ambiguous.\nwarning: refname 'HEAD' is ambiguous.\nOn branch master\nnothing to commit, working directory clean\n\nOh, and git checkout will accept either HEAD or @ to create a branch\nwith the name HEAD anyway:\n\n$ git checkout -b HEAD\nSwitched to a new branch 'HEAD'\n\n$ git checkout -b @\nSwitched to a new branch 'HEAD'\n\nimho none of these should create a branch named HEAD, but should do what\n'git branch HEAD' does and fail with a sensible error message.\n\nAll these shenanigans came up when trying to help an user who is\nmirroring a mercurial repo that has a branch named '@'. Whether or not\ngit should allow branches named '@' I don't have an opinion on, I know\n'@' is pretty special when dealing with refs.\n\n-- \nDennis Kaarsemaker\nwww.kaarsemaker.net\n"}]}