Description
Setup
- Which version of Git for Windows are you using? 32-bit or 64-bit? Include the
output ofgit version
as well.
64 bit git for windows 2.9
$ git --version
git version 2.9.0.windows.1
edit: Still present in 2.9.2.windows.1
-
Which version of Windows are you running? 32-bit or 64-bit?
64-bit Windows 7
-
What options did you set as part of the installation? Or did you choose the
defaults?
filemode = false
preloadindex = false
fscache = false
Also tested with preloadindex
and fscache
, with no change in the results.
- Any other interesting things about your environment that might be related
to the issue you're seeing?
I don't think so.
Details
-
Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
Doesn't matter, git bash or cmd makes no difference.
-
What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
I have created an MCVE repository which can be checked out and used to replicate the issue.
Checkout the repository at: https://github.com/nallar/git-issue-sparse-checkout
git clone https://github.com/nallar/git-issue-sparse-checkout.git mcve-sparse-checkout
cd mcve-sparse-checkout
git checkout other
git checkout master
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
# OR
git checkout -f master
# Now it's showing the correct result again
git status
# no changes
-
What did you expect to occur after running these commands?
Cherry-picking a commit from another branch should not cause files excluded in the sparse checkout rules to be changed.
-
What actually happened instead?
For some reason, the skip-worktree flag gets unset on the file
excluded-folder/1.txt
causing this to show as deleted. Note that the file which broke is a file which was renamed in a commit on theother
branch, but was not renamed in the commit we actually cherry-picked. -
If the problem was occurring with a specific repository, can you provide the
URL to that repository to help us with testing?
https://github.com/nallar/git-issue-sparse-checkout
TL;DR
A file which is excluded by sparse-checkout will show up as deleted in git status after cherry-picking a commit from another branch if any prior commit in that branch renames the file.