Skip to content

Commit d605126

Browse files
committed
Merge branch 'ds/sparse-checkout-clean' into seen
"git sparse-checkout" subcommand learned a new "clean" action to prune otherwise unused working-tree files that are outside the areas of interest. * ds/sparse-checkout-clean: sparse-checkout: make 'clean' clear more files t: expand tests around sparse merges and clean sparse-index: point users to new 'clean' action sparse-checkout: add --verbose option to 'clean' dir: add generic "walk all files" helper sparse-checkout: match some 'clean' behavior sparse-checkout: add basics of 'clean' command sparse-checkout: remove use of the_repository
2 parents 1fa9d01 + eb53242 commit d605126

File tree

7 files changed

+371
-61
lines changed

7 files changed

+371
-61
lines changed

Documentation/git-sparse-checkout.adoc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-sparse-checkout - Reduce your working tree to a subset of tracked files
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git sparse-checkout' (init | list | set | add | reapply | disable | check-rules) [<options>]
12+
'git sparse-checkout' (init | list | set | add | reapply | disable | check-rules | clean) [<options>]
1313

1414

1515
DESCRIPTION
@@ -111,6 +111,29 @@ flags, with the same meaning as the flags from the `set` command, in order
111111
to change which sparsity mode you are using without needing to also respecify
112112
all sparsity paths.
113113

114+
'clean'::
115+
Remove all files in tracked directories that are outside of the
116+
sparse-checkout definition. This subcommand requires cone-mode
117+
sparse-checkout to be sure that we know which directories are
118+
both tracked and all contained paths are not in the sparse-checkout.
119+
This command can be used to be sure the sparse index works
120+
efficiently, though it does not require enabling the sparse index
121+
feature via the `index.sparse=true` configuration.
122+
+
123+
To prevent accidental deletion of worktree files, the `clean` subcommand
124+
will not delete any files without the `-f` or `--force` option, unless
125+
the `clean.requireForce` config option is set to `false`.
126+
+
127+
The `--dry-run` option will list the directories that would be removed
128+
without deleting them. Running in this mode can be helpful to predict the
129+
behavior of the clean comand or to determine which kinds of files are left
130+
in the sparse directories.
131+
+
132+
The `--verbose` option will list every file within the directories that
133+
are considered for removal. This option is helpful to determine if those
134+
files are actually important or perhaps to explain why the directory is
135+
still present despite the current sparse-checkout.
136+
114137
'disable'::
115138
Disable the `core.sparseCheckout` config setting, and restore the
116139
working directory to include all files.

0 commit comments

Comments
 (0)