Why is my file ignored by Git? Somewhere something is telling Git to ignore your file… but where? Is it in a .gitignore file in your current directory, is it in a .gitignore file in a parent directory, or is it in your global Git ignore file? There are many places it could be. The good news is we can ask Git why it is ignoring the file.
git check-ignore -v <yourfile>
e.g.
git check-ignore -v vendor/bin/phpcs
The response gives you three values separated by colons (:)
- the path from the root of the repo to the first place an ignore pattern appears that applies to the given file
- the line number of the ignore pattern
- the ignore pattern
Example:
.gitignore:12:vendor/ vendor/bin/phpcs
See git check-ignore documentation.
Leave a Reply