6 git-sparse-checkout - Initialize and modify the sparse-checkout
7 configuration, which reduces the checkout to a set of paths
8 given by a list of atterns.
14 'git sparse-checkout <subcommand> [options]'
20 Initialize and modify the sparse-checkout configuration, which reduces
21 the checkout to a set of paths given by a list of patterns.
23 THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR, AND THE BEHAVIOR OF OTHER
24 COMMANDS IN THE PRESENCE OF SPARSE-CHECKOUTS, WILL LIKELY CHANGE IN
31 Describe the patterns in the sparse-checkout file.
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.
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.
46 Write a set of patterns to the sparse-checkout file, as given as
47 a list of arguments following the 'set' subcommand. Update the
48 working directory to match the new patterns. Enable the
49 core.sparseCheckout config setting if it is not already enabled.
51 When the `--stdin` option is provided, the patterns are read from
52 standard in as a newline-delimited list instead of from the arguments.
54 When `core.sparseCheckoutCone` is enabled, the input list is considered a
55 list of directories instead of sparse-checkout patterns. The command writes
56 patterns to the sparse-checkout file to include all files contained in those
57 directories (recursively) as well as files that are siblings of ancestor
58 directories. The input format matches the output of `git ls-tree --name-only`.
59 This includes interpreting pathnames that begin with a double quote (") as
60 C-style quoted strings.
63 Update the sparse-checkout file to include additional patterns.
64 By default, these patterns are read from the command-line arguments,
65 but they can be read from stdin using the `--stdin` option. When
66 `core.sparseCheckoutCone` is enabled, the given patterns are interpreted
67 as directory names as in the 'set' subcommand.
70 Disable the `core.sparseCheckout` config setting, and restore the
71 working directory to include all files. Leaves the sparse-checkout
72 file intact so a later 'git sparse-checkout init' command may
73 return the working directory to the same state.
78 "Sparse checkout" allows populating the working directory sparsely.
79 It uses the skip-worktree bit (see linkgit:git-update-index[1]) to tell
80 Git whether a file in the working directory is worth looking at. If
81 the skip-worktree bit is set, then the file is ignored in the working
82 directory. Git will not populate the contents of those files, which
83 makes a sparse checkout helpful when working in a repository with many
84 files, but only a few are important to the current user.
86 The `$GIT_DIR/info/sparse-checkout` file is used to define the
87 skip-worktree reference bitmap. When Git updates the working
88 directory, it updates the skip-worktree bits in the index based
89 on this file. The files matching the patterns in the file will
90 appear in the working directory, and the rest will not.
92 To enable the sparse-checkout feature, run `git sparse-checkout init` to
93 initialize a simple sparse-checkout file and enable the `core.sparseCheckout`
94 config setting. Then, run `git sparse-checkout set` to modify the patterns in
95 the sparse-checkout file.
97 To repopulate the working directory with all files, use the
98 `git sparse-checkout disable` command.
104 By default, the sparse-checkout file uses the same syntax as `.gitignore`
107 While `$GIT_DIR/info/sparse-checkout` is usually used to specify what
108 files are included, you can also specify what files are _not_ included,
109 using negative patterns. For example, to remove the file `unwanted`:
120 The full pattern set allows for arbitrary pattern matches and complicated
121 inclusion/exclusion rules. These can result in O(N*M) pattern matches when
122 updating the index, where N is the number of patterns and M is the number
123 of paths in the index. To combat this performance issue, a more restricted
124 pattern set is allowed when `core.sparseCheckoutCone` is enabled.
126 The accepted patterns in the cone pattern set are:
128 1. *Recursive:* All paths inside a directory are included.
130 2. *Parent:* All files immediately inside a directory are included.
132 In addition to the above two patterns, we also expect that all files in the
133 root directory are included. If a recursive pattern is added, then all
134 leading directories are added as parent patterns.
136 By default, when running `git sparse-checkout init`, the root directory is
137 added as a parent pattern. At this point, the sparse-checkout file contains
138 the following patterns:
145 This says "include everything in root, but nothing two levels below root."
147 When in cone mode, the `git sparse-checkout set` subcommand takes a list of
148 directories instead of a list of sparse-checkout patterns. In this mode,
149 the command `git sparse-checkout set A/B/C` sets the directory `A/B/C` as
150 a recursive pattern, the directories `A` and `A/B` are added as parent
151 patterns. The resulting sparse-checkout file is now
163 Here, order matters, so the negative patterns are overridden by the positive
164 patterns that appear lower in the file.
166 If `core.sparseCheckoutCone=true`, then Git will parse the sparse-checkout file
167 expecting patterns of these types. Git will warn if the patterns do not match.
168 If the patterns do match the expected format, then Git will use faster hash-
169 based algorithms to compute inclusion in the sparse-checkout.
171 In the cone mode case, the `git sparse-checkout list` subcommand will list the
172 directories that define the recursive patterns. For the example sparse-checkout
173 file above, the output is as follows:
175 --------------------------
176 $ git sparse-checkout list
178 --------------------------
180 If `core.ignoreCase=true`, then the pattern-matching algorithm will use a
181 case-insensitive check. This corrects for case mismatched filenames in the
182 'git sparse-checkout set' command to reflect the expected cone in the working
189 If your repository contains one or more submodules, then those submodules will
190 appear based on which you initialized with the `git submodule` command. If
191 your sparse-checkout patterns exclude an initialized submodule, then that
192 submodule will still appear in your working directory.
198 linkgit:git-read-tree[1]
203 Part of the linkgit:git[1] suite