🔀 Git: Fix a Sparse-Checkout Silently Excluding a New Subfolder
Both cone-mode and pattern-mode sparse-checkout match what gets checked out by explicit paths or gitignore-style patterns set up ahead of time – a brand new subfolder added upstream later doesn’t automatically become visible just because it’s a child of an already-included parent, unless the original pattern was written broadly enough (a trailing /* or a parent-level entry) to already cover it. A pattern that named today’s specific subfolders explicitly keeps working for exactly those folders forever, while a new sibling folder added later in that same parent directory simply never appears in the working tree – sparse-checkout’s entire design is to silently not check out whatever isn’t listed, so there’s no warning that anything was left out.
🔎 The Problem
cat .git/info/sparse-checkout src/api/ src/web/ # Upstream adds a new top-level feature area: git pull ls src/ # api/ web/ <- src/billing/ was added upstream but never # appears here - not in the sparse-checkout list, # so it's silently never checked out, no warning
✅ The Fix
- Use cone mode (git sparse-checkout init –cone) with directory-level patterns and periodically run git sparse-checkout list to review exactly what’s currently included, instead of relying on memory of how it was set up originally.
- When a new top-level feature area is added to the repo, add it explicitly with git sparse-checkout add <path> as a deliberate step in that area’s own onboarding process, rather than assuming existing sparse-checkout setups will pick it up on their own.
- If broad coverage of an entire parent directory is actually what’s intended, set the pattern at that parent level (src/*) instead of listing today’s subfolders individually, so a new sibling added later is included by the pattern’s own shape rather than by luck.
🚨 Why This Is Dangerous
A developer working inside a sparse checkout can have no idea a folder even exists in the repository at all, and ‘I don’t see it in my working tree’ is easy to mistake for ‘it doesn’t exist yet’ or ‘it hasn’t been merged,’ sending them looking for an answer in entirely the wrong place.
Sparse-checkout doesn’t warn you about what it’s leaving out – a new folder is invisible by default, not included by default.





