git check-ignore
The command that tells you whether a path is ignored and, with -v, which file, line and pattern ignored it.
In more detail
When a file mysteriously does not show up in git status, git check-ignore -v path answers the question instead of you reading every ignore file. It prints nothing for a path no rule matches.
Example
git check-ignore -v build/out.oRelated terms
- .gitignore — A text file of patterns naming untracked files Git should not report or add, such as build output and logs.
- .git/info/exclude — A private ignore file inside .git that works like .gitignore but is never committed, for clutter only you create.
Taught in
- Ignoring Files, And The Tracked File Trap — Advanced Git Internals & Distributed Workflows