{"thread":{"id":"45623","subject":"Sparse-checkout excluded files show as deleted in git status after some operations","startedAt":"2017-04-06T16:45:40Z","lastAt":"2017-04-06T16:45:40Z","messageCount":1,"participants":["Ross Allan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"316291","messageId":"CABZvOEps9HvViW2bKXEUtTbzy1+UbtM_2muBBycDSwBXOTtF7Q@mail.gmail.com","threadId":"45623","inReplyTo":null,"subject":"Sparse-checkout excluded files show as deleted in git status after some operations","fromName":"Ross Allan","fromEmail":"ross@nallar.me","sentAt":"2017-04-06T16:39:56Z","receivedAt":"2017-04-06T16:45:40Z","isPatch":false,"sender":{"key":"ross@nallar.me","avatar":null},"body":"Hi,\n\nSometimes when working on a repository with files excluded using the\nsparse checkout feature, the skip-worktree flag is incorrectly unset\ncausing files to show as deleted in git status.\n\nInitially I reported this to git-for-windows at\nhttps://github.com/git-for-windows/git/issues/811 but was recommended\nto go here as it is not a windows specific issue (my mistake there).\n\nIt has happened a few times when merging and cherry picking. Here is\nan example repository which can be used to demonstrate the issue:\nhttps://github.com/nallar/git-issue-sparse-checkout\n\nThe following commands run into the issue.\n\ngit clone https://github.com/nallar/git-issue-sparse-checkout.git\nmcve-sparse-checkout\ncd mcve-sparse-checkout\ngit config core.sparseCheckout true\ncp sparse-checkout .git/info/sparse-checkout\ngit checkout -f master\ngit reset --hard HEAD\n# We now have sparse checkout enabled, so the folder \"excluded-folder\"\nshould not be present\nls\n# We should have no changes so far\ngit status\n# Cherry-pick top commit from the other branch\ngit cherry-pick other\n# That cherry-pick succeeded with no conflicts. We should have no\nunstaged changes\ngit status\n# Oh dear, now it shows 'deleted:    excluded-folder/1.txt'\n# Workaround, set skip-worktree which for some reason got unset:\ngit update-index --skip-worktree excluded-folder/1.txt\n# Now it's showing the correct result again\ngit status\n# no changes\n\nFull log demonstrating issue:\nhttps://gist.github.com/anonymous/e1e29f0eb9df25b506fdf555827c73ac\n\nThanks\nRoss Allan\n"}]}