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

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

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

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:48:55

Clemens Buchacher [off-list ref] writes:
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/

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

From: Clemens Buchacher <hidden>
Date: 2016-06-15 22:48:55

On Sun, Jun 06, 2010 at 06:18:56PM +0200, Matthieu Moy wrote:
$ 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.
That is exactly my point. Trying to read the user's mind is not a
solution to this problem. The user does not even know what they are
doing and will inevitably end up even more confused.

The suggestion above would be perfect. It is an easy and obvious
solution, and the user is even educated about their mistake.

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

From: Paolo Bonzini <hidden>
Date: 2016-06-15 22:48:55

On 06/06/2010 06:46 PM, Clemens Buchacher wrote:
That is exactly my point. Trying to read the user's mind is not a
solution to this problem. The user does not even know what they are
doing and will inevitably end up even more confused.
Maybe you just want branch.autosetupmerge = false?

Paolo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help