From: Junio C Hamano <gitster@pobox.com>
To: Dun Peal <dunpealer@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Inconsistent behavior of the path disambiguator
Date: Fri, 29 Oct 2010 11:38:21 -0700 [thread overview]
Message-ID: <7vbp6c7ski.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <AANLkTinM863uZfRxy_1BW1fnfEPsPo8A2m86=Wxh7XGd@mail.gmail.com> (Dun Peal's message of "Fri\, 29 Oct 2010 19\:11\:03 +0100")
Dun Peal <dunpealer@gmail.com> writes:
> When I clone a remote that has a branch `foo`, then `git checkout foo
> --`, the path disamgiuator makes the operation fail. `git checkout
> foo` without the disambiguator works. Following that, when branch
> `foo` already exists, `git checkout foo --` works even with the
> disambiguator that caused it to fail previously.
I do not think there is any bug. You were being bitten by folks who tried
to be helpful for newbies by introducing a(n arguably confusing) special
case; I can see why this is confusing, though.
> $ git checkout foo --
> fatal: invalid reference: foo
Immediately after a clone you would have
refs/heads/master
refs/HEAD -> refs/heads/master
refs/remotes/origin/foo
refs/remotes/origin/whatever-else-you-have
...
and there is no commit that you can name with "foo" when asking git to
check out some paths out of, nor there is no branch that you can name with
"foo" when asking git to check out to work on it.
You can say 'origin/foo', though, in general.
> $ git checkout foo
> Branch foo set up to track remote branch foo from origin.
Asking to check out a branch "foo" in order to work on extending the
history of that branch, when there is _no_ "foo", has a special magic
invented by some folks to "help usability", if there is only one $remote
that has "foo" in it. In this case, you have refs/remotes/origin/foo but
no other refs/remotes/$frotz/foo, and this special magic kicks in.
git behaves as if you meant "git checkout -t -b foo origin/foo" but were
too lazy to type that yourself in this case.
> Switched to a new branch 'foo'
> $ git checkout master
> Switched to branch 'master'
> $ git checkout foo --
> Switched to branch 'foo'
This is referring to local branch "foo", there is nothing magic.
next prev parent reply other threads:[~2010-10-29 18:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-29 18:11 Inconsistent behavior of the path disambiguator Dun Peal
2010-10-29 18:38 ` Junio C Hamano [this message]
2010-10-29 18:54 ` Dun Peal
2010-10-29 20:19 ` Re* " Junio C Hamano
2010-10-29 19:46 ` Jonathan Nieder
2010-10-29 20:25 ` Junio C Hamano
2010-10-29 23:53 ` [PATCH v2] checkout: apply Dscho's dwim even with "--" present Jonathan Nieder
2010-10-29 23:59 ` Jonathan Nieder
2010-10-30 0:41 ` Jonathan Nieder
2010-10-31 3:57 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vbp6c7ski.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=dunpealer@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.