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

Re: DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz"

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 6, 2010, 16:18 UTC
Message-ID
<vpqljas5e33.fsf@bauges.imag.fr>
In-Reply-To
<20100605110930.GA10526@localhost>
Clemens Buchacher <drizzd@aon.at> writes:
Show 14 quoted lines
> Hi,
>
> Peter and I just stumbled on the following interpretations of the
> checkout command.
>
>  git checkout origin/frotz      -> detaches HEAD
>  git checkout -t origin/frotz   -> git checkout -b frotz origin/frotz
>  git checkout frotz             -> git checkout -b frotz origin/frotz
>  git checkout -t frotz          -> fatal: Missing branch name
>
> I was surprised by the third one, which I was expecting to fail.
> Apparently it's a DWIM feature introduced in commit 70c9ac2f. I
> doubt that is what the user was trying to do if they ran that
> command. If anything, this behavior will serve to confuse them.

As already mentionned, it's obviously a bit late to revert the commit which itroduced this DWIM. I tend to agree that this is confusing, but still, this is very often what the user actually wanted. The original patch was to sugest the user the appropriate command, and I find the motivating example rather convincing:

http://thread.gmane.org/gmane.comp.version-control.git/129587
$ git clone git://git.kernel.org/pub/scm/git/git.git
$ cd git
$ git checkout next
error: pathspec 'next' did not match any file(s) known to git.
To create a local branch from the same named remote branch, use
  git checkout -b next origin/next

The newbie does not immediately understand the difference between local and remote branches, he's been told about the branch "next", and wants to check it out.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Johan HerlandNext: Clemens Buchacher
Message 17 of 34 in “DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz"”
  1. Clemens BuchacherJun 5, 2010
  2. Sverre RabbelierJun 5, 2010
  3. Clemens BuchacherJun 5, 2010
  4. Sverre RabbelierJun 5, 2010
  5. Clemens BuchacherJun 5, 2010
  6. Nicolas PitreJun 5, 2010
  7. Jeff KingJun 6, 2010
  8. Clemens BuchacherJun 6, 2010
  9. Jacob HelwigJun 6, 2010
  10. Clemens BuchacherJun 6, 2010
  11. Sverre RabbelierJun 6, 2010
  12. Jacob HelwigJun 6, 2010
  13. Clemens BuchacherJun 7, 2010
  14. Jan KrügerJun 7, 2010
  15. Clemens BuchacherJun 7, 2010
  16. Johan HerlandJun 6, 2010
  17. Matthieu MoyJun 6, 2010
  18. Clemens BuchacherJun 6, 2010
  19. Miles BaderJun 7, 2010
  20. Clemens BuchacherJun 7, 2010
  21. Matthieu MoyJun 7, 2010
  22. Clemens BuchacherJun 7, 2010
  23. Bruce StephensJun 7, 2010
  24. Michael J GruberJun 8, 2010
  25. demerphqJun 8, 2010
  26. Michael J GruberJun 8, 2010
  27. Miles BaderJun 8, 2010
  28. Clemens BuchacherJun 8, 2010
  29. demerphqJun 8, 2010
  30. Matthieu MoyJun 8, 2010
  31. Miles BaderJun 8, 2010
  32. Jeff KingJun 8, 2010
  33. Clemens BuchacherJun 8, 2010
  34. Paolo BonziniJun 7, 2010

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.