Re: master^ is not a local branch -- huh?!?
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 29, 2010, 21:49 UTC
- Message-ID
- <7vr5p8h994.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <alpine.LFD.2.00.1001291614550.1681@xanadu.home>
Nicolas Pitre <nico@fluxnic.net> writes:
Show 12 quoted lines
>> 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.