{"thread":{"id":"45957","subject":"checkout -b remotes/origin/<branch> should not work","startedAt":"2017-05-14T03:52:43Z","lastAt":"2017-05-14T08:00:52Z","messageCount":3,"participants":["Stefan Beller","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"319696","messageId":"CAGZ79kYACtA_q6kJ=gGYe02H-a9g_GV=kKLn8jy2ZZKvjxGYNQ@mail.gmail.com","threadId":"45957","inReplyTo":null,"subject":"checkout -b remotes/origin/<branch> should not work","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-14T03:52:37Z","receivedAt":"2017-05-14T03:52:43Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"NEEDSWORK:\n\ncheckout -b remotes/origin/<branch> should not work, unless force is\ngiven (maybe?)\n\n(I just run into that, now I have a remote tracking branch that points\nat my detached HEAD. Oh well.)\n"},{"id":"319698","messageId":"20170514040048.evwtngo6bixtrput@sigill.intra.peff.net","threadId":"45957","inReplyTo":"CAGZ79kYACtA_q6kJ=gGYe02H-a9g_GV=kKLn8jy2ZZKvjxGYNQ@mail.gmail.com","subject":"Re: checkout -b remotes/origin/<branch> should not work","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-05-14T04:00:49Z","receivedAt":"2017-05-14T04:00:56Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, May 13, 2017 at 08:52:37PM -0700, Stefan Beller wrote:\n\n> NEEDSWORK:\n> \n> checkout -b remotes/origin/<branch> should not work, unless force is\n> given (maybe?)\n> \n> (I just run into that, now I have a remote tracking branch that points\n> at my detached HEAD. Oh well.)\n\nTo be pedantic, you have a local branch with a funny name that points to\nyour detached HEAD. :)\n\nI think this problem extends beyond \"remotes/\". The worst is:\n\n  git checkout -b HEAD\n\nbut there are many confusing variants:\n\n  git checkout -b refs/heads/foo\n  git checkout -b tags/v1.0\n\netc. Those are all perfectly legal names, but almost certainly not what\nthe user intended. I think the plumbing should continue to allow them,\nbut I wouldn't object to some common-sense think-o protections in the\n\"checkout -b\" plumbing (especially if it could be disabled for power\nusers).\n\n-Peff\n"},{"id":"319722","messageId":"xmqqefvr50m3.fsf@gitster.mtv.corp.google.com","threadId":"45957","inReplyTo":"20170514040048.evwtngo6bixtrput@sigill.intra.peff.net","subject":"Re: checkout -b remotes/origin/<branch> should not work","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-14T08:00:36Z","receivedAt":"2017-05-14T08:00:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I think this problem extends beyond \"remotes/\". The worst is:\n>\n>   git checkout -b HEAD\n>\n> but there are many confusing variants:\n>\n>   git checkout -b refs/heads/foo\n>   git checkout -b tags/v1.0\n>\n> etc. Those are all perfectly legal names, but almost certainly not what\n> the user intended. I think the plumbing should continue to allow them,\n> but I wouldn't object to some common-sense think-o protections in the\n> \"checkout -b\" plumbing (especially if it could be disabled for power\n> users).\n\nYup.  I suspect that the last one has uses (for those who may want\nto build on v1.0 tag it is conceivable that a local branch they use\nfor it is named like so), but I agree that anything that begins with\nrefs/* is not something any sane person would want to use.\n\nsanity.branchname configuration or something that tells \"checkout\"\nand \"branch\" Porcelain commands to barf on an attempt to create such\nrefnames does not sound too bad, and making it on by default may not\neven be a bad idea.  But that leads me to say it may not even need\nto be a configurable thing (people who DO want funny names can\nalready and still use the plumbing).\n\nIn any case, no command after such a change should forbid checking\nout such a funny-named branch if it already exists.  We should\ncomplain only on (an attempted) creation.\n\n\n"}]}