{"thread":{"id":"30575","subject":"Is it by design you can create a branch called 'HEAD'?","startedAt":"2012-05-21T09:14:58Z","lastAt":"2012-05-21T22:13:03Z","messageCount":2,"participants":["demerphq","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"191798","messageId":"CANgJU+UAbpFvROFynZ-MHzfhEYksM-Mhf5rVjcA6GUhk6BX-NQ@mail.gmail.com","threadId":"30575","inReplyTo":null,"subject":"Is it by design you can create a branch called 'HEAD'?","fromName":"demerphq","fromEmail":"demerphq@gmail.com","sentAt":"2012-05-21T09:14:58Z","receivedAt":"2012-05-21T09:14:58Z","isPatch":false,"sender":{"key":"demerphq@gmail.com","avatar":null},"body":"One of our devs managed to push a branch called HEAD into our master\nrepository, which then caused various failures for people doing pulls.\n\n   c2014aa..cbe0021  trunk      -> origin/trunk\nerror: Ref refs/remotes/origin/trunk is at\ncbe002152fcc917216ad9003037309893f09901d but expected\nc2014aa485130013ca7eda1cb4a4eef192f9406d\n ! c2014aa...2bb416b HEAD       -> origin/HEAD  (unable to update local ref)\n\nAnd warnings like:\n\n$ git log HEAD\nwarning: refname 'HEAD' is ambiguous.\n\n(we renamed master to 'trunk' long ago for various reasons)\n\nIn order to clean it up we found that there was an entry\n\n2bb416bb4a44fbd61f29479d63a95705a7044e32 refs/heads/HEAD\n\nin our master packed-refs file, along with the normal HEAD file:\n\n$ cat HEAD\nref: refs/heads/trunk\n$ cat refs/heads/trunk\n0752c05e75dd645833fb0ea7ce8e534cbd603f0b\n\nI deleted that line and then we removed these (output of find -ls)\n\n20119672    0 -rw-rw-r--   1 root     cvs             0 May 21 01:26\n./logs/refs/remotes/origin/HEAD\n20120092    4 -rw-rw-r--   1 root     cvs           162 May 21 01:26\n./logs/refs/heads/HEAD\n\nAnd things seemed to be fine. (yes we hillariously call our git user\ngroup cvs :-)\n\nSo I am wondering, did we do the cleanup right?  Is this behavior by\ndesign? What is the most appropriate way to prevent it from happening\nagain?\n\nI will try to find out from the responsible dev if they have their\ncommand history available to see what they did.\n\ncheers,\nYves\n\n-- \nperl -Mre=debug -e \"/just|another|perl|hacker/\"\n"},{"id":"191832","messageId":"7vr4ud6v4g.fsf@alter.siamese.dyndns.org","threadId":"30575","inReplyTo":"CANgJU+UAbpFvROFynZ-MHzfhEYksM-Mhf5rVjcA6GUhk6BX-NQ@mail.gmail.com","subject":"Re: Is it by design you can create a branch called 'HEAD'?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-21T22:13:03Z","receivedAt":"2012-05-21T22:13:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"As you can see from the \"warnings\", we by design strongly discourage it,\nbut just have been (and still are) lazy to think of a reason not to allow\npeople who really want to do so, so the code is lenient if the user asks.\n\nThe plan behind these \"warnings\" obviously is that in future versions of\ngit we would make them even stronger and eventually forbid perhaps all-caps\nnames from anywhere inside refs/ hierarchy.\n"}]}