Skip to content

Commit 6605277

Browse files
gitsterGit for Windows Build Agent
authored andcommitted
Merge branch 'ds/sparse-checkout-clean' into jch
"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: 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 94d92f0 + 592d2a9 commit 6605277

File tree

6 files changed

+411
-58
lines changed

6 files changed

+411
-58
lines changed

Documentation/git-sparse-checkout.adoc

Lines changed: 32 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,37 @@ 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+
Opportunistically remove files outside of the sparse-checkout
116+
definition. This command requires cone mode to use recursive
117+
directory matches to determine which files should be removed. A
118+
file is considered for removal if it is contained within a tracked
119+
directory that is outside of the sparse-checkout definition.
120+
+
121+
Some special cases, such as merge conflicts or modified files outside of
122+
the sparse-checkout definition could lead to keeping files that would
123+
otherwise be removed. Resolve conflicts, stage modifications, and use
124+
`git sparse-checkout reapply` in conjunction with `git sparse-checkout
125+
clean` to resolve these cases.
126+
+
127+
This command can be used to be sure the sparse index works efficiently,
128+
though it does not require enabling the sparse index feature via the
129+
`index.sparse=true` configuration.
130+
+
131+
To prevent accidental deletion of worktree files, the `clean` subcommand
132+
will not delete any files without the `-f` or `--force` option, unless
133+
the `clean.requireForce` config option is set to `false`.
134+
+
135+
The `--dry-run` option will list the directories that would be removed
136+
without deleting them. Running in this mode can be helpful to predict the
137+
behavior of the clean comand or to determine which kinds of files are left
138+
in the sparse directories.
139+
+
140+
The `--verbose` option will list every file within the directories that
141+
are considered for removal. This option is helpful to determine if those
142+
files are actually important or perhaps to explain why the directory is
143+
still present despite the current sparse-checkout.
144+
114145
'disable'::
115146
Disable the `core.sparseCheckout` config setting, and restore the
116147
working directory to include all files.

0 commit comments

Comments
 (0)