Sparse Checkout
In one line
A sparse checkout populates the working tree with only a subset of the repo's files, based on path patterns.
In simple words
A sparse checkout lets you populate your working directory with only a subset of a repository's files. Instead of checking out every file, Git materializes only the paths matching your sparse-checkout patterns. This is invaluable for monorepos where you only need one package's files.
You enable it with git sparse-checkout init, then set patterns with git sparse-checkout set <paths>. Cone mode (the default) is efficient for directory-based patterns. The repo still contains all files in its object store — only the working tree is partial. You can change patterns at any time and Git re-materializes accordingly.
Sparse checkout pairs with partial clone (--filter=blob:none) to avoid even downloading the omitted files' content. Together they let you work with a huge monorepo while only fetching and materializing the parts you touch, dramatically reducing disk usage and clone time.
Example
# Clone a monorepo but only populate one package
git clone --no-checkout https://github.com/org/monorepo.git
cd monorepo
git sparse-checkout init --cone
git sparse-checkout set packages/web
# Now the working tree has only packages/web/*
# The rest of the repo is in the object store but not materialized
# Add another package later
git sparse-checkout add packages/shared--no-checkout skips the initial checkout. sparse-checkout set defines which directories to materialize. Only those paths appear in the working tree.
Related terms
Related Resources
Related Lessons
- Git Advanced
Learn sparse checkout.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.