Home Explore Blog CI



git

1st chunk of `Documentation/git-sparse-checkout.adoc`
2d69678dee4892eae28d50cbb6cbf916725fb8f69d1b04c10000000100000fa3
git-sparse-checkout(1)
======================

NAME
----
git-sparse-checkout - Reduce your working tree to a subset of tracked files


SYNOPSIS
--------
[verse]
'git sparse-checkout' (init | list | set | add | reapply | disable | check-rules) [<options>]


DESCRIPTION
-----------

This command is used to create sparse checkouts, which change the
working tree from having all tracked files present to only having a
subset of those files.  It can also switch which subset of files are
present, or undo and go back to having all tracked files present in
the working copy.

The subset of files is chosen by providing a list of directories in
cone mode (the default), or by providing a list of patterns in
non-cone mode.

When in a sparse-checkout, other Git commands behave a bit differently.
For example, switching branches will not update paths outside the
sparse-checkout directories/patterns, and `git commit -a` will not record
paths outside the sparse-checkout directories/patterns as deleted.

THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR, AND THE BEHAVIOR OF OTHER
COMMANDS IN THE PRESENCE OF SPARSE-CHECKOUTS, WILL LIKELY CHANGE IN
THE FUTURE.


COMMANDS
--------
'list'::
	Describe the directories or patterns in the sparse-checkout file.

'set'::
	Enable the necessary sparse-checkout config settings
	(`core.sparseCheckout`, `core.sparseCheckoutCone`, and
	`index.sparse`) if they are not already set to the desired values,
	populate the sparse-checkout file from the list of arguments
	following the 'set' subcommand, and update the working directory to
	match.
+
To ensure that adjusting the sparse-checkout settings within a worktree
does not alter the sparse-checkout settings in other worktrees, the 'set'
subcommand will upgrade your repository config to use worktree-specific
config if not already present. The sparsity defined by the arguments to
the 'set' subcommand are stored in the worktree-specific sparse-checkout
file. See linkgit:git-worktree[1] and the documentation of
`extensions.worktreeConfig` in linkgit:git-config[1] for more details.
+
When the `--stdin` option is provided, the directories or patterns are
read from standard in as a newline-delimited list instead of from the
arguments.
+
By default, the input list is considered a list of directories, matching
the output of `git ls-tree -d --name-only`.  This includes interpreting
pathnames that begin with a double quote (") as C-style quoted strings.
Note that all files under the specified directories (at any depth) will
be included in the sparse checkout, as well as files that are siblings
of either the given directory or any of its ancestors (see 'CONE PATTERN
SET' below for more details).  In the past, this was not the default,
and `--cone` needed to be specified or `core.sparseCheckoutCone` needed
to be enabled.
+
When `--no-cone` is passed, the input list is considered a list of
patterns.  This mode has a number of drawbacks, including not working
with some options like `--sparse-index`.  As explained in the
"Non-cone Problems" section below, we do not recommend using it.
+
Use the `--[no-]sparse-index` option to use a sparse index (the
default is to not use it).  A sparse index reduces the size of the
index to be more closely aligned with your sparse-checkout
definition. This can have significant performance advantages for
commands such as `git status` or `git add`.  This feature is still
experimental. Some commands might be slower with a sparse index until
they are properly integrated with the feature.
+
**WARNING:** Using a sparse index requires modifying the index in a way
that is not completely understood by external tools. If you have trouble
with this compatibility, then run `git sparse-checkout init --no-sparse-index`
to rewrite your index to not be sparse. Older versions of Git will not
understand the sparse directory entries index extension and may fail to
interact with your repository until it is disabled.

'add'::
	Update the sparse-checkout file to include additional

Title: Git Sparse Checkout
Summary
The git sparse-checkout command is used to reduce the working tree to a subset of tracked files, allowing for more efficient Git operations by only checking out specific files or directories. This command enables sparse checkouts, which can improve performance by limiting the amount of data that needs to be processed, and provides various subcommands to manage and configure sparse checkouts, including init, list, set, add, and disable, each with their own options and functionalities.