Thread (1 message) 1 message, 1 author, 2016-06-15

Re: master^ is not a local branch -- huh?!?

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:08

Nicolas Pitre [off-list ref] writes:
quoted
These days, you can say "git checkout topic" to automagically create a
local "topic" branch that forks from "origin/topic" remote tracking branch
when you have one, thanks to Dscho's UI improvement ideas (one less
reason you may end up on a detached HEAD state without wanting to).
If this is the case then I'm really disappointed.

With all due respects, I don't share Dscho's sentiment about Git's 
alleged non user-friendliness.  And I always praised Git's ability to 
use a detached head to check out a remote branch, and never had any 
problem teaching this concept to people.  So the above is not a UI 
improvement at all to me.
Just in case you misunderstood...

This is "git checkout topic", not "git checkout origin/topic".  The rule
kicks in when you do not have local branch "topic" and there is a unique
"refs/remotes/*/topic".  Existing ways to explicitly ask for detaching are
unaffected, so "checkout origin/topic" or "checkout origin/topic^0" do
what you expect.

We used to just say "topic is not a rev nor path" and failed when the user
sayd "git checkout topic".

Because this cannot be any request other than to check out a local branch
"topic", and because there is no place more sensible than the "topic"
taken from the "origin" (as that is the sole place that has "topic"), it
dwims as a shorthand for "checkout -b topic origin/topic" and tells you
that it did so.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help