threads / discuss / 45623

Sparse-checkout excluded files show as deleted in git status after some operations

Subject: Sparse-checkout excluded files show as deleted in git status after some operations

## tl;dr

One message between Apr 6, 2017 and Apr 6, 2017.

replies: 0people: 1as markdown or json

Ross Allan· Apr 6, 2017, 16:39 UTC · lore
Hi,

Sometimes when working on a repository with files excluded using the sparse checkout feature, the skip-worktree flag is incorrectly unset causing files to show as deleted in git status.

Initially I reported this to git-for-windows at https://github.com/git-for-windows/git/issues/811 but was recommended to go here as it is not a windows specific issue (my mistake there).

It has happened a few times when merging and cherry picking. Here is an example repository which can be used to demonstrate the issue: https://github.com/nallar/git-issue-sparse-checkout

The following commands run into the issue.

git clone https://github.com/nallar/git-issue-sparse-checkout.git mcve-sparse-checkout cd mcve-sparse-checkout git config core.sparseCheckout true cp sparse-checkout .git/info/sparse-checkout git checkout -f master git reset --hard HEAD # We now have sparse checkout enabled, so the folder "excluded-folder" should not be present ls # We should have no changes so far git status # Cherry-pick top commit from the other branch git cherry-pick other # That cherry-pick succeeded with no conflicts. We should have no unstaged changes git status # Oh dear, now it shows 'deleted: excluded-folder/1.txt' # Workaround, set skip-worktree which for some reason got unset: git update-index --skip-worktree excluded-folder/1.txt # Now it's showing the correct result again git status # no changes

Full log demonstrating issue: https://gist.github.com/anonymous/e1e29f0eb9df25b506fdf555827c73ac

Thanks Ross Allan

← back to recent threads