git-sparse-checkout
Reduce working tree to a subset of tracked files
TLDR
SYNOPSIS
git sparse-checkout (init | list | set | add | reapply | disable | check-rules | clean) [options]
DESCRIPTION
git sparse-checkout enables partial repository checkouts, where only specified directories and files are materialized in the working tree. This significantly reduces working directory size for large monorepos.Cone mode (the default) restricts patterns to directory-based inclusion, which is faster and simpler than full pattern matching. In cone mode, the set and add subcommands accept directory names rather than arbitrary gitignore patterns. Non-cone mode (--no-cone) allows arbitrary gitignore-style patterns but is deprecated due to poor performance and confusing semantics.This command is experimental. Its behavior may change in the future.
PARAMETERS
--cone
Use cone mode for directory-based patterns (default, faster).--no-cone
Use full pattern mode for arbitrary gitignore-style patterns.--sparse-index
Enable sparse index format for improved performance.--no-sparse-index
Disable sparse index format for compatibility with external tools.--stdin
Read patterns from stdin (one per line) instead of arguments.-f, --force
Allow cleaning without clean.requireForce config (for clean subcommand).--dry-run
Preview what clean would remove without deleting anything.--rules-file file
Match against rules in specified file instead of current rules (for check-rules).-z
Use NUL-terminated paths for stdin and output (for check-rules).
CONFIGURATION
.git/info/sparse-checkout
File containing the sparse-checkout patterns that control which paths are checked out.
SUBCOMMANDS
init
Deprecated. Use set instead to enable and configure sparse checkout.set
Define which directories/patterns to include in the working tree.add
Add additional directories/patterns to the sparse checkout.list
List the current sparse checkout patterns.disable
Disable sparse checkout and restore all files.reapply
Reapply patterns after manual config changes.check-rules
Check if paths match the current sparsity rules.clean
Remove files outside the sparse-checkout definition. Requires -f unless clean.requireForce is false.
SEE ALSO
git-read-tree(1), git-checkout(1), git-clone(1), git-worktree(1)
