{"thread":{"id":"42029","subject":"Cannot checkout a branch / worktree shows multiple branches for the same directory","startedAt":"2016-04-14T19:51:19Z","lastAt":"2016-04-14T23:12:10Z","messageCount":3,"participants":["Krzysztof Voss","Eric Sunshine","Mike Rappazzo"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"283485","messageId":"CACB1J8XEXcy+Wewcwx_0UWZbQz-WeWUVnK_yAHw5uTBnr2fpVg@mail.gmail.com","threadId":"42029","inReplyTo":null,"subject":"Cannot checkout a branch / worktree shows multiple branches for the same directory","fromName":"Krzysztof Voss","fromEmail":"k.voss@usask.ca","sentAt":"2016-04-14T19:51:19Z","receivedAt":"2016-04-14T19:51:19Z","isPatch":false,"sender":{"key":"k.voss@usask.ca","avatar":null},"body":"Hi,\n\nI stumbled upon an interesting problem when checking out a branch.\nI had to switch to a testing branch to merge in some changes from yet\nanother branch, but when I tried to check out the testing branch I got\na message saying that I'm already on the target branch.\n\nI used worktree a few times, but the checkouts were always in their\nown directories.\nIt crossed my mind that this behaviour may be related, so I took a\nlook at the worktree list and noticed that according to that list\nthere are three branches at the same time in one directory.\n\nIt may be a conicidence and I have no confidence in saying that these\nissues are related.\nCan someone shed some light on this issue for me?\n\n\n    $ git --version\n    git version 2.7.0.235.g07c314d\n\n    $ git status -uno -sb\n    ## ticket-22444\n    M src/core/parsers/ParserBase.py\n    M src/core/parsers/test/ParserBase_test.py\n\n    $ git stash\n    Saved working directory and index state WIP on ticket-22444:\n7c5edaa #22444 refactoring\n    HEAD is now at 7c5edaa #22444 refactoring\n\n    $ git co testing\n    fatal: 'testing' is already checked out at '/home/k/workspace/moyo'\n\n    $ pwd\n    /home/k/workspace/moyo\n\n    $ git branch | grep '*'\n    * ticket-22444\n\n    $ git worktree list\n    /home/k/workspace/moyo  7c5edaa [ticket-22444]\n    /var/home/k/moyo-lsf  349613d (detached HEAD)\n    /home/k/workspace/moyo  265b7f9 (detached HEAD)\n    /home/k/workspace/moyo  c852282 [testing]\n\n    $ uname -a\n    Linux k 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC\n2016 x86_64 x86_64 x86_64 GNU/Linux\n\n    $ cat /etc/lsb-release\n    DISTRIB_ID=Ubuntu\n    DISTRIB_RELEASE=14.04\n    DISTRIB_CODENAME=trusty\n    DISTRIB_DESCRIPTION=\"Ubuntu 14.04.4 LTS\"\n\n\nThanks,\nKrzysztof\n"},{"id":"283502","messageId":"CANoM8SULHrNv7R1COAZ1hq4qCFPX7H0t-v22m6AxUfwNsM_rrQ@mail.gmail.com","threadId":"42029","inReplyTo":"CACB1J8XEXcy+Wewcwx_0UWZbQz-WeWUVnK_yAHw5uTBnr2fpVg@mail.gmail.com","subject":"Re: Cannot checkout a branch / worktree shows multiple branches for the same directory","fromName":"Mike Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2016-04-14T23:11:51Z","receivedAt":"2016-04-14T23:11:51Z","isPatch":false,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"On Thu, Apr 14, 2016 at 3:51 PM, Krzysztof Voss <k.voss@usask.ca> wrote:\n> Hi,\n>\n> I stumbled upon an interesting problem when checking out a branch.\n> I had to switch to a testing branch to merge in some changes from yet\n> another branch, but when I tried to check out the testing branch I got\n> a message saying that I'm already on the target branch.\n>\n> I used worktree a few times, but the checkouts were always in their\n> own directories.\n> It crossed my mind that this behaviour may be related, so I took a\n> look at the worktree list and noticed that according to that list\n> there are three branches at the same time in one directory.\n>\n> It may be a conicidence and I have no confidence in saying that these\n> issues are related.\n> Can someone shed some light on this issue for me?\n>\n>\n>     $ git --version\n>     git version 2.7.0.235.g07c314d\n>\n>     $ git status -uno -sb\n>     ## ticket-22444\n>     M src/core/parsers/ParserBase.py\n>     M src/core/parsers/test/ParserBase_test.py\n>\n>     $ git stash\n>     Saved working directory and index state WIP on ticket-22444:\n> 7c5edaa #22444 refactoring\n>     HEAD is now at 7c5edaa #22444 refactoring\n>\n>     $ git co testing\n>     fatal: 'testing' is already checked out at '/home/k/workspace/moyo'\n>\n>     $ pwd\n>     /home/k/workspace/moyo\n>\n>     $ git branch | grep '*'\n>     * ticket-22444\n>\n>     $ git worktree list\n>     /home/k/workspace/moyo  7c5edaa [ticket-22444]\n>     /var/home/k/moyo-lsf  349613d (detached HEAD)\n>     /home/k/workspace/moyo  265b7f9 (detached HEAD)\n>     /home/k/workspace/moyo  c852282 [testing]\n\nThis looks a lot like the `update_linked_gitdir()` bug that (I\nthought) was fixed[1].  Is\nit possible that you had this problem since before the bug was fixed\nand are just\nnoticing it now?\n\nIf you look in '/home/k/workspace/moyo/.git/worktrees/`  I suspect\nthat there are 3 dirs\nin there, two of which have a file 'gitdir' which have the contents\n'.git'.  These _should_\ninstead point to the '.git' file in your other work trees.  It would\nbe nice to know the last\ntime that those bad worktrees were updated.\n\nIf you know where the other worktrees are located, then you should be able to\nmanually update this file in each of the worktree dirs.\nAlternatively, you can manually\nremove the bad linked worktrees (`rm -r .git/worktrees/bad_wt`).\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/284284\n\n>\n>     $ uname -a\n>     Linux k 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC\n> 2016 x86_64 x86_64 x86_64 GNU/Linux\n>\n>     $ cat /etc/lsb-release\n>     DISTRIB_ID=Ubuntu\n>     DISTRIB_RELEASE=14.04\n>     DISTRIB_CODENAME=trusty\n>     DISTRIB_DESCRIPTION=\"Ubuntu 14.04.4 LTS\"\n>\n>\n> Thanks,\n> Krzysztof\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"283501","messageId":"CAPig+cQXxOLg37au9FQcCC_+=QFnvBRdG6OLBFOTeb5V6rjCiA@mail.gmail.com","threadId":"42029","inReplyTo":"CACB1J8XEXcy+Wewcwx_0UWZbQz-WeWUVnK_yAHw5uTBnr2fpVg@mail.gmail.com","subject":"Re: Cannot checkout a branch / worktree shows multiple branches for the same directory","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-04-14T23:12:10Z","receivedAt":"2016-04-14T23:12:10Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Apr 14, 2016 at 3:51 PM, Krzysztof Voss <k.voss@usask.ca> wrote:\n> I stumbled upon an interesting problem when checking out a branch.\n> I had to switch to a testing branch to merge in some changes from yet\n> another branch, but when I tried to check out the testing branch I got\n> a message saying that I'm already on the target branch.\n>\n> I used worktree a few times, but the checkouts were always in their\n> own directories.\n> It crossed my mind that this behaviour may be related, so I took a\n> look at the worktree list and noticed that according to that list\n> there are three branches at the same time in one directory.\n>\n> It may be a conicidence and I have no confidence in saying that these\n> issues are related.\n> Can someone shed some light on this issue for me?\n>\n>     $ git --version\n>     git version 2.7.0.235.g07c314d\n>\n>     $ git worktree list\n>     /home/k/workspace/moyo  7c5edaa [ticket-22444]\n>     /var/home/k/moyo-lsf  349613d (detached HEAD)\n>     /home/k/workspace/moyo  265b7f9 (detached HEAD)\n>     /home/k/workspace/moyo  c852282 [testing]\n\nDid you manually move any of your worktrees? If so, perhaps this a\nmanifestation of the problem where .git/worktrees/<id>/gitdir got\nincorrectly \"refreshed\" following the move. This issue was \"addressed\"\nby 618244e (worktree: stop supporting moving worktrees manually,\n2016-01-22)[1], which is in git 2.7.2.\n\nUnfortunately, if your gitdir files are already corrupt, upgrading to\ngit 2.7.2 won't recover them; you'll have to fix them manually as\ndescribed by the documentation update included with 618244e[1].\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/284284/focus=284551\n"}]}