Jona Christopher Sahnwaldt <> writes:

> On 25 September 2013 04:51, David Aguilar <> wrote:
>> On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt
>> <> wrote:
>>> Hi,
>>> maybe this has already been reported, but I didn't find it in the mail 
>>> archive.
>>> If I understand correctly, after I clone a repo, I should be able to
>>> switch to branch foo just by running
>>> git checkout foo
>>> This doesn't seem to work if a folder called "foo" exists in the root
>>> of the repo.
>> git checkout foo --
> Thanks for the suggestion, but it doesn't work for me. With both
> and, I get this:
> $ git checkout wiktionary --
> fatal: invalid reference: wiktionary

OK, what happens is that "git checkout wiktionary" is actually a
shorthand for "git checkout -b wiktionary --track origin/wiktionary".

In other words, it does not only "checkout" the branch, but it creates a
local branch with the right name, and checks it out.

The -- disables this shorthand. I'd consider this as a bug. I've just
sent a patch to try to fix this.

> When I try the full branch name:
> $ git checkout origin/wiktionary --
> Note: checking out 'origin/wiktionary'.
> You are in 'detached HEAD' state. You can [...]

This actually checks out the right commit, but does not create a local
branch. That's not a very desirable solution.

In short, this should do the trick:

  git checkout -b wiktionary --track origin/wiktionary

Matthieu Moy
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to