git sparse_checkout ai_generated true

error: sparse-checkout is not enabled. Use 'git sparse-checkout init' to enable it.

ID: git/sparse-checkout-error

Also available as: JSON · Markdown
88%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

Git sparse-checkout commands fail because sparse-checkout is not initialized, or cone mode patterns are incorrectly specified. Often seen when migrating from non-cone sparse-checkout to cone mode or in CI environments.

generic

Workarounds

  1. 90% success Initialize sparse-checkout properly with cone mode
    Run git sparse-checkout init --cone, then git sparse-checkout set <directory1> <directory2> to specify which directories to include.

    Sources: https://git-scm.com/docs/git-sparse-checkout

  2. 85% success Disable cone mode for complex patterns
    Run git sparse-checkout init --no-cone if you need gitignore-style patterns. Then use git sparse-checkout set with pattern syntax.

Dead Ends

Common approaches that don't work:

  1. Editing .git/info/sparse-checkout manually with non-cone patterns while cone mode is enabled 80% fail

    Cone mode expects directory-based patterns; arbitrary gitignore-style patterns are silently ignored or cause errors

  2. Running git read-tree -mu HEAD to force update the working tree 70% fail

    This is the old sparse-checkout mechanism and conflicts with the new sparse-checkout command; it can leave the working tree in an inconsistent state

Error Chain

Leads to:
Preceded by:
Frequently confused with: