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

Re: "git checkout foo" is getting confused by folder named "foo"

From
JSJona Christopher Sahnwaldt <jc@sahnwaldt.de>
Date
Sep 26, 2013, 21:25 UTC
Message-ID
<CAEQewpp9tCAB_N8jzyeUC05fhHNBsgPyLyTqsRaDFMsq5JdqUg@mail.gmail.com>
In-Reply-To
<vpqzjr0oemb.fsf@anie.imag.fr>
On 25 September 2013 22:01, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
Show 18 quoted lines
> Jona Christopher Sahnwaldt <jc@sahnwaldt.de> writes:
>
>> Yes, I think the rules for the "short form" (the guessing when there's
>> no --) should be made simpler, or maybe the guessing should be dropped
>> altogether. I don't know. I don't know git well enough to be able to
>> be more specific. I just find the current behavior very confusing.
>
> It can hardly be "simpler" (in the sense "behavior that can be described
> with fewer words"), but it could be tightened to be safer.
>
> When a remote branch $foo exists, a local branch $foo does not, and a
> file $foo does, then
>
>   git checkout $foo
>
> rather likely means "I want to use git checkout's DWIM and create local
> branch $foo", but it currently means to Git "checkout file foo from the
> index". It would make sense to die here, and require the use of --.

That sounds good. A rule like "when A is true, B is false, and C is true, then X" is probably too complex to be useful. It's probably better to give up and say "sorry, I DKWYM (don't know what you mean)". :-)

There are a few more ideas, opinions, discussions about all this at http://stackoverflow.com/questions/18833617/why-does-git-checkout-remote-branchname-not-create-new-tracking-branch especially in the comments.

Cheers, JC

Show 6 quoted lines
>
> No time to write a patch for this. Any volunteer?
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
Previous: Matthieu Moy
Message 11 of 11 in “"git checkout foo" is getting confused by folder named "foo"”
  1. Jona Christopher SahnwaldtSep 24, 2013
  2. David AguilarSep 25, 2013
  3. Keshav KiniSep 25, 2013
  4. Duy NguyenSep 25, 2013
  5. Jona Christopher SahnwaldtSep 25, 2013
  6. Matthieu MoySep 25, 2013
  7. Jona Christopher SahnwaldtSep 25, 2013
  8. Matthieu MoySep 25, 2013
  9. Jona Christopher SahnwaldtSep 25, 2013
  10. Matthieu MoySep 25, 2013
  11. Jona Christopher SahnwaldtSep 26, 2013

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.