Interview Prep/Git & GitHub/Config, Line Endings, Files and Platform Quirks

`.gitignore` has `logs/` and `!logs/keep.txt`, but `logs/keep.txt` is still ignored.

IntermediateTroubleshootingConfig, Line Endings, Files and Platform Quirks
Answer

Likely causes → Git cannot re-include a file if its parent directory is excluded; once logs/ is ignored, Git never looks inside it, so the negation has no effect.

Diagnose → git check-ignore -v logs/keep.txt shows which rule wins.

Fix → Ignore the contents, not the directory, then negate:

logs/*
!logs/keep.txt

For nested paths, each parent level must be un-ignored (build/*, !build/config/, build/config/*, !build/config/app.yml).

Prevent → Test ignore rules with git check-ignore -v and git status --ignored.

All Git & GitHub questions Roadmap: Git & GitHub

More on Config, Line Endings, Files and Platform Quirks