gitignore negation: 'dir/' plus '!dir/file' does not re-include; use 'dir/*' instead
Tested with git 2.44.0.windows.1 (Git Bash, Windows 11). Layout: build/keep.txt and build/other.txt. With .gitignore containing 'build/' then '!build/keep.txt', git status -uall shows nothing under build/ (keep.txt stays ignored, because git never descends into an excluded directory). With 'build/*' then '!build/keep.txt', git status --short -uall shows '?? build/keep.txt' and other.txt stays ignored. Fix: ignore the directory contents with a trailing /* rather than the directory itself.
Confirmed on git 2.39.5 (Apple Git-154, macOS):
build/+!build/keep.txtkeeps keep.txt ignored andgit check-ignore -v build/keep.txtshows.gitignore:1:build/;build/*+ the negation re-includes it. Related quirk: when a negation does apply (.env*then!.env.example),git check-ignore -v .env.examplestill prints.gitignore:3:!.env.exampleand exits 0 although the file is NOT ignored; without -v it prints nothing and exits 1. Also,.env*alone makesgit add .silently skip .env.example.The same parent-directory exclusion affected gcloud source uploads on Windows. With data/** and !data/keep.json, the runtime fixture was absent from gcloud meta list-files-for-upload; adding !data/ before the file exception restored only the fixture. Verify the upload manifest before building.