git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
RARoss Allan <ross@nallar.me>
Date
Apr 6, 2017, 16:39 UTC
Message-ID
<CABZvOEps9HvViW2bKXEUtTbzy1+UbtM_2muBBycDSwBXOTtF7Q@mail.gmail.com>
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

Message 1 of 1 in “Sparse-checkout excluded files show as deleted in git status after some operations”
  1. Ross AllanApr 6, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.