{"thread":{"id":"35010","subject":"\"git checkout foo\" is getting confused by folder named \"foo\"","startedAt":"2013-09-24T21:07:53Z","lastAt":"2013-09-26T21:25:09Z","messageCount":11,"participants":["Jona Christopher Sahnwaldt","David Aguilar","Keshav Kini","Duy Nguyen","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"228176","messageId":"CAEQewpqLcDJPo2gUWPk-xc3OitdTC4gH2tnyqaURiQ77BApNog@mail.gmail.com","threadId":"35010","inReplyTo":null,"subject":"\"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Jona Christopher Sahnwaldt","fromEmail":"jc@sahnwaldt.de","sentAt":"2013-09-24T21:07:53Z","receivedAt":"2013-09-24T21:07:53Z","isPatch":false,"sender":{"key":"jc@sahnwaldt.de","avatar":null},"body":"Hi,\n\nmaybe this has already been reported, but I didn't find it in the mail archive.\n\nIf I understand correctly, after I clone a repo, I should be able to\nswitch to branch foo just by running\n\ngit checkout foo\n\nThis doesn't seem to work if a folder called \"foo\" exists in the root\nof the repo.\n\nI got the same behavior with git 1.8.3.2 on a Mac and git 1.7.9.5 on Linux.\n\nSteps to reproduce:\n\ngit clone https://github.com/dbpedia/extraction-framework.git\ncd extraction-framework/\n\nFirst the happy path - there is a remote branch \"live-dev\", but no\nfolder \"extraction-framework/live-dev\":\n\ngit checkout live-dev\n\nResponse:\n\nBranch live-dev set up to track remote branch live-dev from origin.\nSwitched to a new branch 'live-dev'\n\nFine! Now the unhappy path - there is a branch \"wiktionary\", but also\na folder \"extraction-framework/wiktionary\":\n\ngit checkout wiktionary\n\nNothing - no response, no changes to working tree. .git/index seems to\nbe modified though.\n\nSlightly different - cd to some folder, try checkout again:\n\ncd mappings\ngit checkout wiktionary\n\nResponse:\n\nerror: pathspec 'wiktionary' did not match any file(s) known to git.\n\n\nMy workaround is that when I switch to a branch for the first time, I\nhave to call\n\ngit checkout -t -b wiktionary --track origin/wiktionary\n\nResponse:\n\nBranch wiktionary set up to track remote branch wiktionary from origin.\nSwitched to a new branch 'wiktionary'\n\nLooks good. After that, I can switch back and forth between branches\njust by git checkout wiktionary / git checkout master.\n\n\nCheers,\nChristopher\n"},{"id":"228188","messageId":"CAJDDKr64ou+gO7WJLFZ4zOSv+VCbkiW7nKuZa9=5_fiSqGUeyQ@mail.gmail.com","threadId":"35010","inReplyTo":"CAEQewpqLcDJPo2gUWPk-xc3OitdTC4gH2tnyqaURiQ77BApNog@mail.gmail.com","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2013-09-25T02:51:14Z","receivedAt":"2013-09-25T02:51:14Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt\n<jc@sahnwaldt.de> wrote:\n> Hi,\n>\n> maybe this has already been reported, but I didn't find it in the mail archive.\n>\n> If I understand correctly, after I clone a repo, I should be able to\n> switch to branch foo just by running\n>\n> git checkout foo\n>\n> This doesn't seem to work if a folder called \"foo\" exists in the root\n> of the repo.\n\ngit checkout foo --\n\nThe double-dash at the end disambiguates between refs and paths.\n\nYou can use that trick on any command that accepts refspec (branches,\ntags, etc) and pathspec (path patterns).\n-- \nDavid\n"},{"id":"228189","messageId":"87y56lsie0.fsf@gmail.com","threadId":"35010","inReplyTo":"CAJDDKr64ou+gO7WJLFZ4zOSv+VCbkiW7nKuZa9=5_fiSqGUeyQ@mail.gmail.com","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Keshav Kini","fromEmail":"keshav.kini@gmail.com","sentAt":"2013-09-25T03:13:43Z","receivedAt":"2013-09-25T03:13:43Z","isPatch":false,"sender":{"key":"keshav.kini@gmail.com","avatar":"https://avatars.githubusercontent.com/u/691290?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt\n> <jc@sahnwaldt.de> wrote:\n>> Hi,\n>>\n>> maybe this has already been reported, but I didn't find it in the mail archive.\n>>\n>> If I understand correctly, after I clone a repo, I should be able to\n>> switch to branch foo just by running\n>>\n>> git checkout foo\n>>\n>> This doesn't seem to work if a folder called \"foo\" exists in the root\n>> of the repo.\n>\n> git checkout foo --\n>\n> The double-dash at the end disambiguates between refs and paths.\n>\n> You can use that trick on any command that accepts refspec (branches,\n> tags, etc) and pathspec (path patterns).\n\nI was going to reply with similar advice, but I actually tried it on the\nexample repo and it didn't work. Apparently it doesn't interoperate\nproperly with the functionality that guesses when you're trying to check\nout a remote branch and creates an equivalently named local branch.\n\n    [2] fs@erdos /tmp $ git clone https://github.com/dbpedia/extraction-framework.git\n    Cloning into 'extraction-framework'...\n    remote: Counting objects: 33513, done.\n    remote: Compressing objects: 100% (6633/6633), done.\n    remote: Total 33513 (delta 19000), reused 32922 (delta 18436)\n    Receiving objects: 100% (33513/33513), 23.48 MiB | 747.00 KiB/s, done.\n    Resolving deltas: 100% (19000/19000), done.\n    Checking connectivity... done\n    [2] fs@erdos /tmp $ cd extraction-framework/\n    [2] fs@erdos /tmp/extraction-framework $ git checkout live-dev --\n    fatal: invalid reference: live-dev\n    [2] fs@erdos /tmp/extraction-framework $ git checkout live-dev\n    Branch live-dev set up to track remote branch live-dev from origin.\n    Switched to a new branch 'live-dev'\n    [2] fs@erdos /tmp/extraction-framework $ git checkout master\n    Switched to branch 'master'\n    [2] fs@erdos /tmp/extraction-framework $ git checkout wiktionary\n    [2] fs@erdos /tmp/extraction-framework $ git branch\n      live-dev\n    * master\n    [2] fs@erdos /tmp/extraction-framework $ git checkout wiktionary --\n    fatal: invalid reference: wiktionary\n\n-Keshav\n"},{"id":"228190","messageId":"CACsJy8DO8ck-ZWuzFbYJyK=mpAkyC+7_vaOfOixd3ahWje7CEA@mail.gmail.com","threadId":"35010","inReplyTo":"87y56lsie0.fsf@gmail.com","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-09-25T03:33:27Z","receivedAt":"2013-09-25T03:33:27Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Sep 25, 2013 at 10:13 AM, Keshav Kini <keshav.kini@gmail.com> wrote:\n>     [2] fs@erdos /tmp/extraction-framework $ git checkout wiktionary --\n>     fatal: invalid reference: wiktionary\n\nIt may work if we demote this from fatal to error warning so the dwim\nlogic in checkout has a chance to try differently, I think.\n-- \nDuy\n"},{"id":"228196","messageId":"CAEQewpqbf-sWSt0GS9eXQNi0yFz5-23NcO2JWKO4OgSFv3SXdA@mail.gmail.com","threadId":"35010","inReplyTo":"CAJDDKr64ou+gO7WJLFZ4zOSv+VCbkiW7nKuZa9=5_fiSqGUeyQ@mail.gmail.com","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Jona Christopher Sahnwaldt","fromEmail":"jc@sahnwaldt.de","sentAt":"2013-09-25T08:58:53Z","receivedAt":"2013-09-25T08:58:53Z","isPatch":false,"sender":{"key":"jc@sahnwaldt.de","avatar":null},"body":"On 25 September 2013 04:51, David Aguilar <davvid@gmail.com> wrote:\n> On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt\n> <jc@sahnwaldt.de> wrote:\n>> Hi,\n>>\n>> maybe this has already been reported, but I didn't find it in the mail archive.\n>>\n>> If I understand correctly, after I clone a repo, I should be able to\n>> switch to branch foo just by running\n>>\n>> git checkout foo\n>>\n>> This doesn't seem to work if a folder called \"foo\" exists in the root\n>> of the repo.\n>\n> git checkout foo --\n\nThanks for the suggestion, but it doesn't work for me. With both\n1.7.9.5 and 1.8.3.2, I get this:\n\n$ git checkout wiktionary --\nfatal: invalid reference: wiktionary\n\nWhen I try the full branch name:\n\n$ git checkout origin/wiktionary --\nNote: checking out 'origin/wiktionary'.\nYou are in 'detached HEAD' state. You can [...]\n\n:-(\n\nChristopher\n\n>\n> The double-dash at the end disambiguates between refs and paths.\n>\n> You can use that trick on any command that accepts refspec (branches,\n> tags, etc) and pathspec (path patterns).\n> --\n> David\n"},{"id":"228202","messageId":"vpqzjr1ujyn.fsf@anie.imag.fr","threadId":"35010","inReplyTo":"CAEQewpqbf-sWSt0GS9eXQNi0yFz5-23NcO2JWKO4OgSFv3SXdA@mail.gmail.com","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-09-25T13:09:04Z","receivedAt":"2013-09-25T13:09:04Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Jona Christopher Sahnwaldt <jc@sahnwaldt.de> writes:\n\n> On 25 September 2013 04:51, David Aguilar <davvid@gmail.com> wrote:\n>> On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt\n>> <jc@sahnwaldt.de> wrote:\n>>> Hi,\n>>>\n>>> maybe this has already been reported, but I didn't find it in the mail archive.\n>>>\n>>> If I understand correctly, after I clone a repo, I should be able to\n>>> switch to branch foo just by running\n>>>\n>>> git checkout foo\n>>>\n>>> This doesn't seem to work if a folder called \"foo\" exists in the root\n>>> of the repo.\n>>\n>> git checkout foo --\n>\n> Thanks for the suggestion, but it doesn't work for me. With both\n> 1.7.9.5 and 1.8.3.2, I get this:\n>\n> $ git checkout wiktionary --\n> fatal: invalid reference: wiktionary\n\nOK, what happens is that \"git checkout wiktionary\" is actually a\nshorthand for \"git checkout -b wiktionary --track origin/wiktionary\".\n\nIn other words, it does not only \"checkout\" the branch, but it creates a\nlocal branch with the right name, and checks it out.\n\nThe -- disables this shorthand. I'd consider this as a bug. I've just\nsent a patch to try to fix this.\n\n> When I try the full branch name:\n>\n> $ git checkout origin/wiktionary --\n> Note: checking out 'origin/wiktionary'.\n> You are in 'detached HEAD' state. You can [...]\n\nThis actually checks out the right commit, but does not create a local\nbranch. That's not a very desirable solution.\n\nIn short, this should do the trick:\n\n  git checkout -b wiktionary --track origin/wiktionary\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"228218","messageId":"CAEQewpoD2VRVtpEyG121TqAptoYfEXxt57CCthBX_EfN7LU0fQ@mail.gmail.com","threadId":"35010","inReplyTo":"vpqzjr1ujyn.fsf@anie.imag.fr","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Jona Christopher Sahnwaldt","fromEmail":"jc@sahnwaldt.de","sentAt":"2013-09-25T16:24:20Z","receivedAt":"2013-09-25T16:24:20Z","isPatch":false,"sender":{"key":"jc@sahnwaldt.de","avatar":null},"body":"Hi everyone,\n\ntl;dr: The short form \"git checkout foo\" is a mess. There's simply too\nmuch \"DWIM\" magic going on. There are no comprehensible rules how it\ndecides if \"foo\" is a pathspec or a refspec.\n\n\nOn 25 September 2013 15:09, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n> Jona Christopher Sahnwaldt <jc@sahnwaldt.de> writes:\n>\n>> On 25 September 2013 04:51, David Aguilar <davvid@gmail.com> wrote:\n>>> On Tue, Sep 24, 2013 at 2:07 PM, Jona Christopher Sahnwaldt\n>>> <jc@sahnwaldt.de> wrote:\n>>>> Hi,\n>>>>\n>>>> maybe this has already been reported, but I didn't find it in the mail archive.\n>>>>\n>>>> If I understand correctly, after I clone a repo, I should be able to\n>>>> switch to branch foo just by running\n>>>>\n>>>> git checkout foo\n>>>>\n>>>> This doesn't seem to work if a folder called \"foo\" exists in the root\n>>>> of the repo.\n>>>\n>>> git checkout foo --\n>>\n>> Thanks for the suggestion, but it doesn't work for me. With both\n>> 1.7.9.5 and 1.8.3.2, I get this:\n>>\n>> $ git checkout wiktionary --\n>> fatal: invalid reference: wiktionary\n>\n> OK, what happens is that \"git checkout wiktionary\" is actually a\n> shorthand for \"git checkout -b wiktionary --track origin/wiktionary\".\n\nNo, it isn't. More precisely: if branch \"foo\" is not yet in\n.git/config, but there is a branch \"origin/foo\" and no file/folder\n\"foo\" in the root of the project, then \"git checkout foo\" is short for\n\"git checkout -b foo -t origin/foo\" (which in turn can be shortened to\n\"git checkout -t origin/foo\", if I understand correctly).\n\nBelow are the rather arcane rules that I found in 1.7.9.5. They apply\nif the branch \"foo\" is not yet configured in .git/config. If branch\n\"foo\" is in .git/config  I guess \"git checkout foo\" will always check\nout branch \"foo\", no matter if there's a file called \"foo\" somewhere.\n\nI gave up testing them in 1.8.3.2, but I assume its behavior the same.\n\nLet's consider several scenarios:\n\n1. there is a branch \"origin/foo\", but also a *tracked* file/folder\n\"foo\" in the *root* folder of the project:\n\na. when I'm in the root folder, \"git checkout foo\" silently resets the\nworking tree file/folder \"foo\" to its staged / HEAD version (I think)\nand prints no response.\n\nb. when I'm in a sub-folder that contains a tracked file/folder called\n\"foo\", \"git checkout foo\" silently resets the working tree file/folder\n\"foo\" to its staged / HEAD version and prints no response\n\nc. when I'm in a sub-folder that cotains *no* *tracked* file/folder\ncalled \"foo\", \"git checkout foo\" does nothing and prints \"error:\npathspec 'foo' did not match any file(s) known to git.\"\n\n2. there is a branch \"origin/foo\", but also an *untracked* file/folder\n\"foo\" in the *root* folder of the project:\n\na. when I'm in the root folder, \"git checkout foo\" does nothing and\nprints \"error: pathspec 'foo' did not match any file(s) known to git.\"\n\nb. when I'm in a sub-folder containing a *tracked* file/folder \"foo\",\n\"git checkout foo\" silently resets the working tree file/folder \"foo\"\nto its staged / HEAD version and prints no response\n\nc. when I'm in a sub-folder that contains *no* *tracked* file/folder\ncalled \"foo\", \"git checkout foo\" does nothing and prints \"error:\npathspec 'foo' did not match any file(s) known to git.\"\n\n3. there is a branch \"origin/foo\", but *no*  file/folder \"foo\" in the\n*root* folder of the project:\n\na. if I'm in the root folder (no tracked or untracked file/folder\n\"foo\"), \"git checkout foo\" switches to branch \"foo\" which tracks\n\"origin/foo\":\n\nb. if I'm in a sub-folder with a (tracked or untracked) file/folder\n\"foo\", \"git checkout foo\" switches to branch \"foo\" which tracks\n\"origin/foo\":\n\n4. there is *no* branch \"origin/foo\"\n\na. when I'm in root or sub-folder that contains a *tracked*\nfile/folder called \"foo\", \"git checkout foo\" silently resets the\nworking tree file/folder \"foo\" to its staged / HEAD version and prints\nno response\n\nb. when I'm in root or sub-folder that cotains *no* *tracked*\nfile/folder called \"foo\", \"git checkout foo\" does nothing and prints\n\"error: pathspec 'foo' did not match any file(s) known to git.\"\n\n\nAll right, I guess there are more cases, but let's leave it at that...\n\n\n>\n> In other words, it does not only \"checkout\" the branch, but it creates a\n> local branch with the right name, and checks it out.\n\nNo, in my case, it doesn't, because there is a folder called \"wiktionary\".\n\n>\n> The -- disables this shorthand. I'd consider this as a bug. I've just\n> sent a patch to try to fix this.\n>\n>> When I try the full branch name:\n>>\n>> $ git checkout origin/wiktionary --\n>> Note: checking out 'origin/wiktionary'.\n>> You are in 'detached HEAD' state. You can [...]\n>\n> This actually checks out the right commit, but does not create a local\n> branch. That's not a very desirable solution.\n>\n> In short, this should do the trick:\n>\n>   git checkout -b wiktionary --track origin/wiktionary\n\nYes, I know, as I said in my original mail. By the way, I later found\nthat I can shorten this to \"git checkout -t origin/wiktionary\".\n\nJC\n\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n"},{"id":"228225","messageId":"vpqzjr0pvfn.fsf@anie.imag.fr","threadId":"35010","inReplyTo":"CAEQewpoD2VRVtpEyG121TqAptoYfEXxt57CCthBX_EfN7LU0fQ@mail.gmail.com","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-09-25T19:12:28Z","receivedAt":"2013-09-25T19:12:28Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Jona Christopher Sahnwaldt <jc@sahnwaldt.de> writes:\n\n> Hi everyone,\n>\n> tl;dr: The short form \"git checkout foo\" is a mess. There's simply too\n> much \"DWIM\" magic going on. There are no comprehensible rules how it\n> decides if \"foo\" is a pathspec or a refspec.\n\nThere is a very simple rule:\n\nWhat's on the left hand side of -- are refs, what's on the right hand\nside are paths.\n\nWhen you don't use --, then Git tries to guess, and fails whenever\nthere's an ambiguity.\n\n>> OK, what happens is that \"git checkout wiktionary\" is actually a\n>> shorthand for \"git checkout -b wiktionary --track origin/wiktionary\".\n>\n> No, it isn't.\n\nWhat I meant was that the short form advised by people were _meant_ to\nbe a shorthand.\n\n> Let's consider several scenarios:\n\nI don't get your point. Is the overly long list a way of complaining?\nAre you suggesting a change? What do you think about the change I'm\nproposing?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"228230","messageId":"CAEQewpoRhGGnc7HMES1nNbduiRP-qLF4hKBJhRKy7CjMzXnGNg@mail.gmail.com","threadId":"35010","inReplyTo":"vpqzjr0pvfn.fsf@anie.imag.fr","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Jona Christopher Sahnwaldt","fromEmail":"jc@sahnwaldt.de","sentAt":"2013-09-25T19:36:52Z","receivedAt":"2013-09-25T19:36:52Z","isPatch":false,"sender":{"key":"jc@sahnwaldt.de","avatar":null},"body":"On 25 September 2013 21:12, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n> Jona Christopher Sahnwaldt <jc@sahnwaldt.de> writes:\n>\n>> Hi everyone,\n>>\n>> tl;dr: The short form \"git checkout foo\" is a mess. There's simply too\n>> much \"DWIM\" magic going on. There are no comprehensible rules how it\n>> decides if \"foo\" is a pathspec or a refspec.\n>\n> There is a very simple rule:\n>\n> What's on the left hand side of -- are refs, what's on the right hand\n> side are paths.\n>\n> When you don't use --, then Git tries to guess, and fails whenever\n> there's an ambiguity.\n\nThat's the case I'm concerned with. And I think the guessing confuses\nusers in many cases. It certainly has confused me.\n\n>\n>>> OK, what happens is that \"git checkout wiktionary\" is actually a\n>>> shorthand for \"git checkout -b wiktionary --track origin/wiktionary\".\n>>\n>> No, it isn't.\n>\n> What I meant was that the short form advised by people were _meant_ to\n> be a shorthand.\n>\n>> Let's consider several scenarios:\n>\n> I don't get your point. Is the overly long list a way of complaining?\n\nIt's a way of showing that human beings can't understand git's\nguesswork. :-) It was also a (failed) attempt to understand the rules\nof this heuristic. And an attempt to show the developers that the\nrules have gotten out of hand.\n\n> Are you suggesting a change?\n\nYes, I think the rules for the \"short form\" (the guessing when there's\nno --) should be made simpler, or maybe the guessing should be dropped\naltogether. I don't know. I don't know git well enough to be able to\nbe more specific. I just find the current behavior very confusing.\n\n> What do you think about the change I'm proposing?\n\nI don't know. It looks like it's not really addressing my specific\nproblem, because as far as I understand it only applies when there is\na --. But again, I don't know git well enough.\n\nAnyway, thanks for your work. I'm sorry I can't provide more useful\ninput. This \"short form\" of checkout is just a small feature. I guess\nI'm bikeshedding here.\n\nCheers,\nJC\n\n\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n"},{"id":"228234","messageId":"vpqzjr0oemb.fsf@anie.imag.fr","threadId":"35010","inReplyTo":"CAEQewpoRhGGnc7HMES1nNbduiRP-qLF4hKBJhRKy7CjMzXnGNg@mail.gmail.com","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-09-25T20:01:00Z","receivedAt":"2013-09-25T20:01:00Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Jona Christopher Sahnwaldt <jc@sahnwaldt.de> writes:\n\n> Yes, I think the rules for the \"short form\" (the guessing when there's\n> no --) should be made simpler, or maybe the guessing should be dropped\n> altogether. I don't know. I don't know git well enough to be able to\n> be more specific. I just find the current behavior very confusing.\n\nIt can hardly be \"simpler\" (in the sense \"behavior that can be described\nwith fewer words\"), but it could be tightened to be safer.\n\nWhen a remote branch $foo exists, a local branch $foo does not, and a\nfile $foo does, then\n\n  git checkout $foo\n\nrather likely means \"I want to use git checkout's DWIM and create local\nbranch $foo\", but it currently means to Git \"checkout file foo from the\nindex\". It would make sense to die here, and require the use of --.\n\nNo time to write a patch for this. Any volunteer?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"228295","messageId":"CAEQewpp9tCAB_N8jzyeUC05fhHNBsgPyLyTqsRaDFMsq5JdqUg@mail.gmail.com","threadId":"35010","inReplyTo":"vpqzjr0oemb.fsf@anie.imag.fr","subject":"Re: \"git checkout foo\" is getting confused by folder named \"foo\"","fromName":"Jona Christopher Sahnwaldt","fromEmail":"jc@sahnwaldt.de","sentAt":"2013-09-26T21:25:09Z","receivedAt":"2013-09-26T21:25:09Z","isPatch":false,"sender":{"key":"jc@sahnwaldt.de","avatar":null},"body":"On 25 September 2013 22:01, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n> Jona Christopher Sahnwaldt <jc@sahnwaldt.de> writes:\n>\n>> Yes, I think the rules for the \"short form\" (the guessing when there's\n>> no --) should be made simpler, or maybe the guessing should be dropped\n>> altogether. I don't know. I don't know git well enough to be able to\n>> be more specific. I just find the current behavior very confusing.\n>\n> It can hardly be \"simpler\" (in the sense \"behavior that can be described\n> with fewer words\"), but it could be tightened to be safer.\n>\n> When a remote branch $foo exists, a local branch $foo does not, and a\n> file $foo does, then\n>\n>   git checkout $foo\n>\n> rather likely means \"I want to use git checkout's DWIM and create local\n> branch $foo\", but it currently means to Git \"checkout file foo from the\n> index\". It would make sense to die here, and require the use of --.\n\nThat sounds good. A rule like \"when A is true, B is false, and C is\ntrue, then X\" is probably too complex to be useful. It's probably\nbetter to give up and say \"sorry, I DKWYM (don't know what you mean)\".\n:-)\n\nThere are a few more ideas, opinions, discussions about all this at\nhttp://stackoverflow.com/questions/18833617/why-does-git-checkout-remote-branchname-not-create-new-tracking-branch\nespecially in the comments.\n\nCheers,\nJC\n>\n> No time to write a patch for this. Any volunteer?\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n"}]}