Make huge repos workable on small disks.
Materialize only some directories of the repo into the working tree. The rest exists in .git/ but isn't checked out. Essential for huge monorepos.
Sparse-checkout configures the skip-worktree bit on index entries you don't want materialized. The object DB stays complete; the working tree is partial. Two modes: cone (directory-prefix matching, fast) and non-cone (full pathspec, more flexible).
git sparse-checkout (init|list|set|add|reapply|disable|check-rules) [<options>]| Flag | What it does |
|---|---|
init [--cone] | Enable sparse-checkout with cone mode (recommended). |
set <patterns>... | Define which paths to include. |
add <patterns>... | Add to the existing pattern set. |
list | Show current patterns. |
disable | Restore full checkout. |
$ git sparse-checkout init --cone$ git sparse-checkout set src/ docs/$ git sparse-checkout add tests/$ git sparse-checkout list.gitattributes changes.$ git sparse-checkout reapply$ git sparse-checkout disable$ echo 'src/main.c' | git sparse-checkout check-rules$ git sparse-checkout init --cone
$ git sparse-checkout set src/ docs/$ git sparse-checkout add tests/$ git sparse-checkout disable--filter=blob:none on clone for true partial-clone benefit.Hit each option, then Check answers. Score is recorded; Next is always open.