git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: checkout -b remotes/origin/<branch> should not work

From
Jeff King <peff@peff.net>
Date
May 14, 2017, 04:00 UTC
Message-ID
<20170514040048.evwtngo6bixtrput@sigill.intra.peff.net>
In-Reply-To
<CAGZ79kYACtA_q6kJ=gGYe02H-a9g_GV=kKLn8jy2ZZKvjxGYNQ@mail.gmail.com>
On Sat, May 13, 2017 at 08:52:37PM -0700, Stefan Beller wrote:
Show 7 quoted lines
> NEEDSWORK:
> 
> checkout -b remotes/origin/<branch> should not work, unless force is
> given (maybe?)
> 
> (I just run into that, now I have a remote tracking branch that points
> at my detached HEAD. Oh well.)

To be pedantic, you have a local branch with a funny name that points to your detached HEAD. :)

I think this problem extends beyond "remotes/". The worst is:
  git checkout -b HEAD
but there are many confusing variants:
  git checkout -b refs/heads/foo
  git checkout -b tags/v1.0

etc. Those are all perfectly legal names, but almost certainly not what the user intended. I think the plumbing should continue to allow them, but I wouldn't object to some common-sense think-o protections in the "checkout -b" plumbing (especially if it could be disabled for power users).

-Peff
Previous: Stefan BellerNext: Junio C Hamano
Message 2 of 3 in “checkout -b remotes/origin/<branch> should not work”
  1. Stefan BellerMay 14, 2017
  2. Jeff KingMay 14, 2017
  3. Junio C HamanoMay 14, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.