Check Out Only Part of a Repo With sparse-checkout

Reduce a huge working tree to the directories you actually edit.

macOSperformancegitcliLow risk
Run git sparse-checkout set src/ docs/ to keep only those paths in the working tree.

01Command

Command
$ git sparse-checkout set src/ docs/

02What it does

Sparse checkout lets you clone a monorepo but materialize only a subset of paths, saving disk and IDE indexing time while keeping full history available. It is a terminal-first feature for large-scale development.

03Risk

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!Warning: Files outside the sparse set appear deleted to tools that scan the filesystem; remember they still exist in the repository.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Developer