1GIT-SPARSE-CHECKOU(1)             Git Manual             GIT-SPARSE-CHECKOU(1)
2
3
4

NAME

6       git-sparse-checkout - Initialize and modify the sparse-checkout
7       configuration, which reduces the checkout to a set of paths given by a
8       list of patterns.
9

SYNOPSIS

11       git sparse-checkout <subcommand> [options]
12

DESCRIPTION

14       Initialize and modify the sparse-checkout configuration, which reduces
15       the checkout to a set of paths given by a list of patterns.
16
17       THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR, AND THE BEHAVIOR OF OTHER
18       COMMANDS IN THE PRESENCE OF SPARSE-CHECKOUTS, WILL LIKELY CHANGE IN THE
19       FUTURE.
20

COMMANDS

22       list
23           Describe the patterns in the sparse-checkout file.
24
25       init
26           Enable the core.sparseCheckout setting. If the sparse-checkout file
27           does not exist, then populate it with patterns that match every
28           file in the root directory and no other directories, then will
29           remove all directories tracked by Git. Add patterns to the
30           sparse-checkout file to repopulate the working directory.
31
32           To avoid interfering with other worktrees, it first enables the
33           extensions.worktreeConfig setting and makes sure to set the
34           core.sparseCheckout setting in the worktree-specific config file.
35
36           When --cone is provided, the core.sparseCheckoutCone setting is
37           also set, allowing for better performance with a limited set of
38           patterns (see CONE PATTERN SET below).
39
40       set
41           Write a set of patterns to the sparse-checkout file, as given as a
42           list of arguments following the set subcommand. Update the working
43           directory to match the new patterns. Enable the core.sparseCheckout
44           config setting if it is not already enabled.
45
46           When the --stdin option is provided, the patterns are read from
47           standard in as a newline-delimited list instead of from the
48           arguments.
49
50           When core.sparseCheckoutCone is enabled, the input list is
51           considered a list of directories instead of sparse-checkout
52           patterns. The command writes patterns to the sparse-checkout file
53           to include all files contained in those directories (recursively)
54           as well as files that are siblings of ancestor directories. The
55           input format matches the output of git ls-tree --name-only. This
56           includes interpreting pathnames that begin with a double quote (")
57           as C-style quoted strings.
58
59       add
60           Update the sparse-checkout file to include additional patterns. By
61           default, these patterns are read from the command-line arguments,
62           but they can be read from stdin using the --stdin option. When
63           core.sparseCheckoutCone is enabled, the given patterns are
64           interpreted as directory names as in the set subcommand.
65
66       disable
67           Disable the core.sparseCheckout config setting, and restore the
68           working directory to include all files. Leaves the sparse-checkout
69           file intact so a later git sparse-checkout init command may return
70           the working directory to the same state.
71

SPARSE CHECKOUT

73       "Sparse checkout" allows populating the working directory sparsely. It
74       uses the skip-worktree bit (see git-update-index(1)) to tell Git
75       whether a file in the working directory is worth looking at. If the
76       skip-worktree bit is set, then the file is ignored in the working
77       directory. Git will not populate the contents of those files, which
78       makes a sparse checkout helpful when working in a repository with many
79       files, but only a few are important to the current user.
80
81       The $GIT_DIR/info/sparse-checkout file is used to define the
82       skip-worktree reference bitmap. When Git updates the working directory,
83       it updates the skip-worktree bits in the index based on this file. The
84       files matching the patterns in the file will appear in the working
85       directory, and the rest will not.
86
87       To enable the sparse-checkout feature, run git sparse-checkout init to
88       initialize a simple sparse-checkout file and enable the
89       core.sparseCheckout config setting. Then, run git sparse-checkout set
90       to modify the patterns in the sparse-checkout file.
91
92       To repopulate the working directory with all files, use the git
93       sparse-checkout disable command.
94

FULL PATTERN SET

96       By default, the sparse-checkout file uses the same syntax as .gitignore
97       files.
98
99       While $GIT_DIR/info/sparse-checkout is usually used to specify what
100       files are included, you can also specify what files are not included,
101       using negative patterns. For example, to remove the file unwanted:
102
103           /*
104           !unwanted
105

CONE PATTERN SET

107       The full pattern set allows for arbitrary pattern matches and
108       complicated inclusion/exclusion rules. These can result in O(N*M)
109       pattern matches when updating the index, where N is the number of
110       patterns and M is the number of paths in the index. To combat this
111       performance issue, a more restricted pattern set is allowed when
112       core.sparseCheckoutCone is enabled.
113
114       The accepted patterns in the cone pattern set are:
115
116        1. Recursive: All paths inside a directory are included.
117
118        2. Parent: All files immediately inside a directory are included.
119
120       In addition to the above two patterns, we also expect that all files in
121       the root directory are included. If a recursive pattern is added, then
122       all leading directories are added as parent patterns.
123
124       By default, when running git sparse-checkout init, the root directory
125       is added as a parent pattern. At this point, the sparse-checkout file
126       contains the following patterns:
127
128           /*
129           !/*/
130
131       This says "include everything in root, but nothing two levels below
132       root."
133
134       When in cone mode, the git sparse-checkout set subcommand takes a list
135       of directories instead of a list of sparse-checkout patterns. In this
136       mode, the command git sparse-checkout set A/B/C sets the directory
137       A/B/C as a recursive pattern, the directories A and A/B are added as
138       parent patterns. The resulting sparse-checkout file is now
139
140           /*
141           !/*/
142           /A/
143           !/A/*/
144           /A/B/
145           !/A/B/*/
146           /A/B/C/
147
148       Here, order matters, so the negative patterns are overridden by the
149       positive patterns that appear lower in the file.
150
151       If core.sparseCheckoutCone=true, then Git will parse the
152       sparse-checkout file expecting patterns of these types. Git will warn
153       if the patterns do not match. If the patterns do match the expected
154       format, then Git will use faster hash- based algorithms to compute
155       inclusion in the sparse-checkout.
156
157       In the cone mode case, the git sparse-checkout list subcommand will
158       list the directories that define the recursive patterns. For the
159       example sparse-checkout file above, the output is as follows:
160
161           $ git sparse-checkout list
162           A/B/C
163
164       If core.ignoreCase=true, then the pattern-matching algorithm will use a
165       case-insensitive check. This corrects for case mismatched filenames in
166       the git sparse-checkout set command to reflect the expected cone in the
167       working directory.
168

SUBMODULES

170       If your repository contains one or more submodules, then those
171       submodules will appear based on which you initialized with the git
172       submodule command. If your sparse-checkout patterns exclude an
173       initialized submodule, then that submodule will still appear in your
174       working directory.
175

SEE ALSO

177       git-read-tree(1) gitignore(5)
178

GIT

180       Part of the git(1) suite
181
182
183
184Git 2.26.2                        2020-04-20             GIT-SPARSE-CHECKOU(1)
Impressum