@@ -30,28 +30,36 @@ COMMANDS
30
30
'list'::
31
31
Describe the patterns in the sparse-checkout file.
32
32
33
- 'init '::
34
- Enable the `core.sparseCheckout` setting. If the
35
- sparse-checkout file does not exist, then populate it with
36
- patterns that match every file in the root directory and
37
- no other directories, then will remove all directories tracked
38
- by Git. Add patterns to the sparse-checkout file to
39
- repopulate the working directory .
33
+ 'set '::
34
+ Enable the necessary config settings
35
+ (extensions.worktreeConfig, core.sparseCheckout,
36
+ core.sparseCheckoutCone) if they are not already enabled, and
37
+ write a set of patterns to the sparse-checkout file from the
38
+ list of arguments following the 'set' subcommand. Update the
39
+ working directory to match the new patterns .
40
40
+
41
- To avoid interfering with other worktrees, it first enables the
42
- `extensions.worktreeConfig` setting and makes sure to set the
43
- `core.sparseCheckout` setting in the worktree-specific config file.
41
+ When the `--stdin` option is provided, the patterns are read from
42
+ standard in as a newline-delimited list instead of from the arguments.
44
43
+
45
- When `--cone` is provided, the `core.sparseCheckoutCone` setting is
46
- also set, allowing for better performance with a limited set of
47
- patterns (see 'CONE PATTERN SET' below).
44
+ When `--cone` is passed or `core.sparseCheckoutCone` is enabled, the
45
+ input list is considered a list of directories instead of
46
+ sparse-checkout patterns. This allows for better performance with a
47
+ limited set of patterns (see 'CONE PATTERN SET' below). Note that the
48
+ set command will write patterns to the sparse-checkout file to include
49
+ all files contained in those directories (recursively) as well as
50
+ files that are siblings of ancestor directories. The input format
51
+ matches the output of `git ls-tree --name-only`. This includes
52
+ interpreting pathnames that begin with a double quote (") as C-style
53
+ quoted strings. This may become the default in the future; --no-cone
54
+ can be passed to request non-cone mode.
48
55
+
49
- Use the `--[no-]sparse-index` option to toggle the use of the sparse
50
- index format. This reduces the size of the index to be more closely
51
- aligned with your sparse-checkout definition. This can have significant
52
- performance advantages for commands such as `git status` or `git add`.
53
- This feature is still experimental. Some commands might be slower with
54
- a sparse index until they are properly integrated with the feature.
56
+ Use the `--[no-]sparse-index` option to use a sparse index (the
57
+ default is to not use it). A sparse index reduces the size of the
58
+ index to be more closely aligned with your sparse-checkout
59
+ definition. This can have significant performance advantages for
60
+ commands such as `git status` or `git add`. This feature is still
61
+ experimental. Some commands might be slower with a sparse index until
62
+ they are properly integrated with the feature.
55
63
+
56
64
**WARNING:** Using a sparse index requires modifying the index in a way
57
65
that is not completely understood by external tools. If you have trouble
@@ -60,23 +68,6 @@ to rewrite your index to not be sparse. Older versions of Git will not
60
68
understand the sparse directory entries index extension and may fail to
61
69
interact with your repository until it is disabled.
62
70
63
- 'set'::
64
- Write a set of patterns to the sparse-checkout file, as given as
65
- a list of arguments following the 'set' subcommand. Update the
66
- working directory to match the new patterns. Enable the
67
- core.sparseCheckout config setting if it is not already enabled.
68
- +
69
- When the `--stdin` option is provided, the patterns are read from
70
- standard in as a newline-delimited list instead of from the arguments.
71
- +
72
- When `core.sparseCheckoutCone` is enabled, the input list is considered a
73
- list of directories instead of sparse-checkout patterns. The command writes
74
- patterns to the sparse-checkout file to include all files contained in those
75
- directories (recursively) as well as files that are siblings of ancestor
76
- directories. The input format matches the output of `git ls-tree --name-only`.
77
- This includes interpreting pathnames that begin with a double quote (") as
78
- C-style quoted strings.
79
-
80
71
'add'::
81
72
Update the sparse-checkout file to include additional patterns.
82
73
By default, these patterns are read from the command-line arguments,
@@ -93,12 +84,35 @@ C-style quoted strings.
93
84
cases, it can make sense to run `git sparse-checkout reapply` later
94
85
after cleaning up affected paths (e.g. resolving conflicts, undoing
95
86
or committing changes, etc.).
87
+ +
88
+ The `reapply` command can also take `--[no-]cone` and `--[no-]sparse-index`
89
+ flags, with the same meaning as the flags from the `set` command, in order
90
+ to change which sparsity mode you are using without needing to also respecify
91
+ all sparsity paths.
96
92
97
93
'disable'::
98
94
Disable the `core.sparseCheckout` config setting, and restore the
99
- working directory to include all files. Leaves the sparse-checkout
100
- file intact so a later 'git sparse-checkout init' command may
101
- return the working directory to the same state.
95
+ working directory to include all files.
96
+
97
+ 'init'::
98
+ Deprecated command that behaves like `set` with no specified paths.
99
+ May be removed in the future.
100
+ +
101
+ Historically, `set` did not handle all the necessary config settings,
102
+ which meant that both `init` and `set` had to be called. Invoking
103
+ both meant the `init` step would first remove nearly all tracked files
104
+ (and in cone mode, ignored files too), then the `set` step would add
105
+ many of the tracked files (but not ignored files) back. In addition
106
+ to the lost files, the performance and UI of this combination was
107
+ poor.
108
+ +
109
+ Also, historically, `init` would not actually initialize the
110
+ sparse-checkout file if it already existed. This meant it was
111
+ possible to return to a sparse-checkout without remembering which
112
+ paths to pass to a subsequent 'set' or 'add' command. However,
113
+ `--cone` and `--sparse-index` options would not be remembered across
114
+ the disable command, so the easy restore of calling a plain `init`
115
+ decreased in utility.
102
116
103
117
SPARSE CHECKOUT
104
118
---------------
@@ -107,7 +121,7 @@ SPARSE CHECKOUT
107
121
It uses the skip-worktree bit (see linkgit:git-update-index[1]) to tell
108
122
Git whether a file in the working directory is worth looking at. If
109
123
the skip-worktree bit is set, then the file is ignored in the working
110
- directory. Git will not populate the contents of those files, which
124
+ directory. Git will avoid populating the contents of those files, which
111
125
makes a sparse checkout helpful when working in a repository with many
112
126
files, but only a few are important to the current user.
113
127
@@ -117,10 +131,8 @@ directory, it updates the skip-worktree bits in the index based
117
131
on this file. The files matching the patterns in the file will
118
132
appear in the working directory, and the rest will not.
119
133
120
- To enable the sparse-checkout feature, run `git sparse-checkout init` to
121
- initialize a simple sparse-checkout file and enable the `core.sparseCheckout`
122
- config setting. Then, run `git sparse-checkout set` to modify the patterns in
123
- the sparse-checkout file.
134
+ To enable the sparse-checkout feature, run `git sparse-checkout set` to
135
+ set the patterns you want to use.
124
136
125
137
To repopulate the working directory with all files, use the
126
138
`git sparse-checkout disable` command.
0 commit comments