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

Re: git checkout -b origin/mybranch origin/mybranch

From
John Tapsell <johnflux@gmail.com>
Date
Mar 12, 2009, 16:16 UTC
Message-ID
<43d8ce650903120916yb91113fy5485813c512c8108@mail.gmail.com>
In-Reply-To
<20090312153738.GA24690@coredump.intra.peff.net>
2009/3/12 Jeff King <peff@peff.net>:
Show 28 quoted lines
> On Thu, Mar 12, 2009 at 03:21:48PM +0000, Pieter de Bie wrote:
>
>> You can also get this in other interactions, for example:
>>
>>       $ git checkout -b origin/test HEAD
>>       $ git checkout -b origin/test master
>>
>> yes, these might be user errors, but I still think it's not OK to create a
>> new ref 'refs/heads/origin/test' if there's also a 'refs/
>> remotes/origin/test' (as I've said a few months ago).
>
> One thing that has been missing from this discussion (and I think you
> are getting to it here) is a concrete rule for "X is harmful, and Y is
> not". That is, how do we know when to warn, and then what do we do?
>
> John's original example was "git checkout -b origin/test origin/test".
> So it's a problem that they're textually the same, but obviously there
> are more problematic cases.
>
> The behavior I think you are implying would be something like:
>
>  When making origin/test, try to resolve_ref("origin/test"); if it
>  fails, we are OK. If it succeeds, then we know we will be creating an
>  ambiguity. Complain and refuse the creation unless "-f" is given.
>
> This would actually be a superset of the "branch already exists" case,
> so it should be pretty simple to code, and it makes for a simple rule:
> it is now "ref already exists".
+1

I was thinking more along the lines of checking if it begins with remotes/, origin/, tags/, stash/, bisect/ and blacklisting these.

Can anyone suggest a reason that you really might want to create a branch called origin/something ?

> Does that actually cover all of the problematic cases?
>
> -Peff
>
Previous: Jeff KingNext: Jeff King
Message 12 of 20 in “git checkout -b origin/mybranch origin/mybranch”
  1. John TapsellMar 12, 2009
  2. Sverre RabbelierMar 12, 2009
  3. Johannes SchindelinMar 12, 2009
  4. John TapsellMar 12, 2009
  5. Johannes SchindelinMar 12, 2009
  6. John TapsellMar 12, 2009
  7. Sverre RabbelierMar 12, 2009
  8. John TapsellMar 12, 2009
  9. Michael J GruberMar 13, 2009
  10. Pieter de BieMar 12, 2009
  11. Jeff KingMar 12, 2009
  12. John TapsellMar 12, 2009
  13. Jeff KingMar 12, 2009
  14. Pieter de BieMar 12, 2009
  15. Jeff KingMar 12, 2009
  16. John TapsellMar 12, 2009
  17. Jeff KingMar 12, 2009
  18. John TapsellMar 12, 2009
  19. John TapsellMar 12, 2009
  20. Junio C HamanoMar 12, 2009

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.