git/list[1] front-page[2] threads[3] people[4] search[5] about
 

"git checkout foo" is getting confused by folder named "foo"

From
JSJona Christopher Sahnwaldt <jc@sahnwaldt.de>
Date
Sep 24, 2013, 21:07 UTC
Message-ID
<CAEQewpqLcDJPo2gUWPk-xc3OitdTC4gH2tnyqaURiQ77BApNog@mail.gmail.com>
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.

I got the same behavior with git 1.8.3.2 on a Mac and git 1.7.9.5 on Linux.
Steps to reproduce:

git clone https://github.com/dbpedia/extraction-framework.git cd extraction-framework/

First the happy path - there is a remote branch "live-dev", but no folder "extraction-framework/live-dev":

git checkout live-dev
Response:

Branch live-dev set up to track remote branch live-dev from origin. Switched to a new branch 'live-dev'

Fine! Now the unhappy path - there is a branch "wiktionary", but also a folder "extraction-framework/wiktionary":

git checkout wiktionary

Nothing - no response, no changes to working tree. .git/index seems to be modified though.

Slightly different - cd to some folder, try checkout again:

cd mappings git checkout wiktionary

Response:
error: pathspec 'wiktionary' did not match any file(s) known to git.

My workaround is that when I switch to a branch for the first time, I have to call

git checkout -t -b wiktionary --track origin/wiktionary
Response:

Branch wiktionary set up to track remote branch wiktionary from origin. Switched to a new branch 'wiktionary'

Looks good. After that, I can switch back and forth between branches just by git checkout wiktionary / git checkout master.

Cheers, Christopher

Next: David Aguilar
Message 1 of 11 in “"git checkout foo" is getting confused by folder named "foo"”
  1. Jona Christopher SahnwaldtSep 24, 2013
  2. David AguilarSep 25, 2013
  3. Keshav KiniSep 25, 2013
  4. Duy NguyenSep 25, 2013
  5. Jona Christopher SahnwaldtSep 25, 2013
  6. Matthieu MoySep 25, 2013
  7. Jona Christopher SahnwaldtSep 25, 2013
  8. Matthieu MoySep 25, 2013
  9. Jona Christopher SahnwaldtSep 25, 2013
  10. Matthieu MoySep 25, 2013
  11. Jona Christopher SahnwaldtSep 26, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.