Skip to main content

Use git check-ignore to debug your .gitignore

Running git check-ignore --verbose <PATH> will tell you which rule applies to a given path, and where that rule is defined.

Here’s a useful thing I learnt today: you can use git check-ignore to debug your gitignore rules and find out why a particular file is (or isn’t) being ignored. It knows all the places where gitignore rules might be defined, and how Git decides between conflicting rules.

A few examples: