Interview Prep/Git & GitHub/Repository Health, Size and Performance

`git add` prints `The following paths and/or pathspecs matched paths that exist outside of your sparse-checkout definition, so will not be updated in the index:`

IntermediateTroubleshootingRepository Health, Size and Performance
Answer

Likely causes → You are in a sparse checkout (cone mode) and the file you edited or created is outside the configured directories. Git protects sparse entries from accidental updates.

Diagnose →

git sparse-checkout list
git config core.sparseCheckout

Fix → Add the directory to the sparse definition, then add the file:

git sparse-checkout add services/payments
git add services/payments/handler.go

For a one-off you can force it with git add --sparse <path>.

Prevent → Document which directories each team needs and provide a git sparse-checkout set ... command per team in the onboarding guide.

All Git & GitHub questions Roadmap: Git & GitHub

More on Repository Health, Size and Performance