git sparse-checkout set: Usage, Options & Common CI Errors
By Daniel Zoghalchali·Latchkey
git sparse-checkout set limits which directories Git materializes in the working tree.
In a large monorepo, sparse-checkout lets a CI job check out only the paths it builds, cutting checkout time and disk. Cone mode keeps the patterns simple and fast.
What it does
git sparse-checkout set defines the set of paths present in the working tree; everything outside the patterns is left out. git sparse-checkout init enables the feature, and disable turns it off and restores a full checkout.
An empty working tree after set usually means cone mode plus a path that does not exist, or non-cone patterns that match nothing - verify with git sparse-checkout list and that the paths exist in the commit. Combine with a partial clone (--filter=blob:none) to avoid downloading excluded blobs at all.
Frequently asked questions
git sparse-checkout set: Usage, Options & Common CI Errors?
In a large monorepo, sparse-checkout lets a CI job check out only the paths it builds, cutting checkout time and disk. Cone mode keeps the patterns simple and fast.
What it does?
git sparse-checkout set defines the set of paths present in the working tree; everything outside the patterns is left out. git sparse-checkout init enables the feature, and disable turns it off and restores a full checkout.
Common errors in CI?
An empty working tree after set usually means cone mode plus a path that does not exist, or non-cone patterns that match nothing - verify with git sparse-checkout list and that the paths exist in the commit. Combine with a partial clone (--filter=blob:none) to avoid downloading excluded blobs at all.
Latchkey managed runners at $0.0025/min at 2 vCPU, against $0.006 GitHub-hosted, and transient failures repaired on the runner.Start free →30-day trial · No credit card
Cookie Preferences
Choose which categories of cookies you want to allow. Essential cookies are always active as they are required for the site to function.
Essential
Required for the site to function.
Functional
Remembers your preferences like selected workspace and dashboard settings.
Analytics
Helps us understand how the site is used (Google Analytics).