DEV Community

Suyash Bhandare
Suyash Bhandare

Posted on

.gitignore Not Working? Here's a Quick Fix

If .gitignore isn't ignoring a file, check these first:

  1. Is the file already tracked?

git ls-files --error-unmatch path/to/file

If it is tracked:

git rm --cached path/to/file

  1. Find which rule matches:

git check-ignore -v path/to/file

  1. Test a tracked file against your rules:

git check-ignore -v --no-index path/to/file

  1. Check for other ignore sources:

Nested .gitignore files
.git/info/exclude
Global Git excludes

  1. Check your pattern carefully. build/, build/, and build/* don't mean exactly the same thing.

I built IgnoreDebugger to make this easier — paste your .gitignore rules and a file path to see which rule matches and why.

https://ignoredebugger.com

git #github #webdev #programming

Top comments (0)