]> git.ipfire.org Git - thirdparty/git.git/commit
sparse-checkout: match some 'clean' behavior
authorDerrick Stolee <stolee@gmail.com>
Fri, 12 Sep 2025 10:30:07 +0000 (10:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Sep 2025 15:59:52 +0000 (08:59 -0700)
commita8077c19131a86fa123c5be2c8b735acdb5dacf4
treee7404b92f0294a0965bf282216f02a04a5c6a247
parent2520efd3bc8c81cb4bd8f832b241c3b2b8c0630f
sparse-checkout: match some 'clean' behavior

The 'git sparse-checkout clean' subcommand is somewhat similar to 'git
clean' in that it will delete files that should not be in the worktree.
The big difference is that it focuses on the directories that should not
be in the worktree due to cone-mode sparse-checkout. It also does not
discriminate in the kinds of files and focuses on deleting entire
directories.

However, there are some restrictions that would be good to bring over
from 'git clean', specifically how it refuses to do anything without the
'-f'/'--force' or '-n'/'--dry-run' arguments. The 'clean.requireForce'
config can be set to 'false' to imply '--force'.

Add this behavior to avoid accidental deletion of files that cannot be
recovered from Git.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-sparse-checkout.adoc
builtin/sparse-checkout.c
t/t1091-sparse-checkout-builtin.sh