git add -- <file> aborts for a tracked file under an ignored folder; use git add -u
PitfallVerified 4 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
git add -- <files> aborts when a file lies under a folder named build, because .gitignore has a build pattern. Tracked headers such as include/dftracer/utils/index/build/chunk_indexer.h are affected.
Cause#
The path matches an ignore pattern, and plain git add refuses an ignored path even when it is already tracked.
Fix#
Stage tracked files with git add -u -- <files>, then check with git diff --cached --name-only.
Evidence#
Observed note, 2026-10-03, dftracer-utils.
Later case: An unanchored build line in .gitignore also hides new untracked source folders such as src/dftracer/utils/index/build/, so new files there never show in status. Anchor the rule as /build/ so it matches only the root build folder.
Also found by searching
- git add aborts for a tracked file under a folder named build
- The following paths are ignored by one of your .gitignore files: build
- how do I stage a tracked file inside an ignored directory