By admin , 29 April 2026

Why sparse

Sparse checkout populates only a subset of a repo's working tree, while keeping all metadata and history. For monorepos, this can mean checking out 1% of files and ignoring the other 99%, drastically speeding up git status, IDE indexing, and disk usage.

Cone mode

Modern Git (2.25+) introduces "cone mode" which restricts patterns to whole directories rather than arbitrary globs, in exchange for far better performance.

git sparse-checkout init --cone
git sparse-checkout set apps/web libs/shared
git sparse-checkout add apps/admin
git sparse-checkout list

The cone covers all files at the root and inside the listed directories.

Non-cone mode

For arbitrary patterns, omit --cone and edit .git/info/sparse-checkout directly. Useful for include/exclude patterns:

git sparse-checkout init
cat > .git/info/sparse-checkout <<'EOF'
/*
!/build/
!/legacy/
EOF
git read-tree -m -u HEAD

Cloning sparse

git clone --filter=blob:none --no-checkout https://example.com/big.git
cd big
git sparse-checkout init --cone
git sparse-checkout set apps/web
git checkout main

Combined with partial clone (--filter=blob:none), you fetch only the blobs you need on demand. See "Partial clone: promise and promisor remotes".

Checking the index

Files outside the sparse cone are marked with skip-worktree in the index:

git ls-files -t | head
git update-index --skip-worktree path
git update-index --no-skip-worktree path

Disabling

git sparse-checkout disable

Restores the full working tree.

Common mistakes

Editing files outside the cone — they may exist if previously checked out but are not tracked by sparse mode; commit unexpected behavior. Use cone mode unless patterns truly require it; non-cone is much slower. Forgetting that git add warns when you stage a path outside the sparse set unless core.sparseCheckoutCone=true is set.

Sparse index

Pair sparse checkout with the sparse index to skip recording the excluded paths in the index entirely:

git sparse-checkout init --cone --sparse-index
git config index.sparse true

See "The sparse index: operating without a full index".

Related

See "Sparse checkout for monorepos" and "Partial clone: promise and promisor remotes".