{"thread":{"id":"41367","subject":"git worktree loses path information after git reset --hard","startedAt":"2016-02-08T08:07:10Z","lastAt":"2016-02-08T19:49:01Z","messageCount":2,"participants":["Daniel Egger","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"277714","messageId":"A1270C54-3868-42F4-8F7E-8F444631078F@eggers-club.de","threadId":"41367","inReplyTo":null,"subject":"git worktree loses path information after git reset --hard","fromName":"Daniel Egger","fromEmail":"daniel@eggers-club.de","sentAt":"2016-02-08T08:07:10Z","receivedAt":"2016-02-08T08:07:10Z","isPatch":false,"sender":{"key":"daniel@eggers-club.de","avatar":null},"body":"Hi guys,\n\nI stumbled across a problem with worktrees recently; I incorrectly opened a ticket a GitHub for that and it was suggested that it might be fixed in 2.7.1 so I held off reporting it here but as it turned out it is still broken in 2.7.1 so here we go.\n\nThe problem is that the paths of the worktrees in $GIT_DIR/worktrees/worktree_name/gitdir are rewritten to read .git instead of /path/to/worktree/root/.git after a git reset --hard (and potentially other operations) which causes all worktrees in git worktree list to point to the current worktree instead of the main repository path.\n\nLet me demonstrate:\n\n# git worktree list\n/Users/user/Desktop/Source/Product          2991e32 [master]\n/Users/user/Desktop/Source/Product-2.1      3fc1082 [releases/master-2.1]\n/Users/user/Desktop/Source/Product-2.2      3ccc3fe [releases/master-2.2]\n/Users/user/Desktop/Source/Product-2.3      4044881 [releases/master-2.3]\n# cd /Users/user/Desktop/Source/Product-2.1\n# git reset --hard\n# cd /Users/user/Desktop/Source/Product-2.2\n# git reset --hard\n# cd /Users/user/Desktop/Source/Product\n# git worktree list\n/Users/user/Desktop/Source/Product          2991e32 [master]\n/Users/user/Desktop/Source/Product          3fc1082 [releases/master-2.1]\n/Users/user/Desktop/Source/Product          3ccc3fe [releases/master-2.2]\n/Users/user/Desktop/Source/Product-2.3      4044881 [releases/master-2.3]\n\nServus,\n      Daniel\n"},{"id":"277758","messageId":"xmqqh9hj7zki.fsf@gitster.mtv.corp.google.com","threadId":"41367","inReplyTo":"A1270C54-3868-42F4-8F7E-8F444631078F@eggers-club.de","subject":"Re: git worktree loses path information after git reset --hard","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-08T19:49:01Z","receivedAt":"2016-02-08T19:49:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Egger <daniel@eggers-club.de> writes:\n\n> I stumbled across a problem with worktrees recently; I incorrectly\n> opened a ticket a GitHub for that and it was suggested that it\n> might be fixed in 2.7.1 so I held off reporting it here but as it\n> turned out it is still broken in 2.7.1 so here we go.\n\nInstead of holding off, report them early after checking the list\narchive to see if it is already resolved.  You may be asked to\nverify the proposed fix works for you with this and that patch, and\nyou can help us that way, too, in addition to your helping us by\nthrowing us a bug report.\n\nI think the fix for this particular one is cooking in 'next' and\nabout to graduate to 'master' (hence hopefully it can be part of\n2.7.2).\n\nThanks.\n"}]}