Home > OS >  How to `Disable or modify the sparsity rules`?
How to `Disable or modify the sparsity rules`?

Time:10-13

kes@work ~/t/etc $ git rm local.conf 
The following pathspecs didn't match any eligible path, but they do match index
entries outside the current sparse checkout:
local.conf
hint: Disable or modify the sparsity rules if you intend to update such entries.
hint: Disable this message with "git config advice.updateSparsePath false"

Earlier I did: git update-index --skip-worktree etc/local.conf

How to Disable or modify the sparsity rules?

CodePudding user response:

The hints are for newbies, who aren't expected to issue core commands directly.

skip-worktree is the internal flag used to mark a path that's in the commit but not part of the checkout. Git's got a convenience facility, "sparse checkout", say git help sparse-checkout if you're curious, that allows you to ... well, do sparse checkouts, of only the paths you want to work with, and completely ignore whatever's at other paths in the commit. This turns out to be very handy in situations not many ever encounter.

When the index entry has that flag lit, Git's internals literally skip every operation that would affect or reference the path in the work tree, but they keep the index entry around to remind themselves that the path is out of bounds.

The hint is written assuming you lit that flag by using the sparse checkout facility. There's nothing wrong with using the flag yourself the way you did, but the newbie hints weren't written with you in mind, so they presume you're doing something which it turns out you hadn't yet encountered in the docs.

If what you want to do is to remove that file and index entry, unset the skip-worktree flag first, with git update-index --no-skip-worktree etc/local.conf, and then git rm will work as expected.

If what you want to do is to just remove the index entry, you can do that directly, at the core-command level, git update-index --force-remove etc/local.conf, or unset the flag as above then git rm --cached it.

  • Related