Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

How do you find out which rule is ignoring a file?

SHORT ANSWER

Run git check-ignore -v path. It prints the file, line number and pattern of the rule that matches, which helps when a file unexpectedly does not show up in git status.

Explain it simply

You created config/local.js and git status shows nothing. Somewhere a rule is eating it, but your repo may have several gitignore files plus the global one.

git check-ignore -v config/local.js answers precisely: it shows which file, which line and which pattern matched. No output means the file is not ignored. To add an ignored file anyway use git add -f, but treat that as a last resort.

Example

bash
git check-ignore -v config/local.js
# .gitignore:4:*.js   config/local.js
git add -f config/local.js

What to say in the interview

"git check-ignore -v shows the exact gitignore file, line and pattern that ignores a path. It saves guessing when a file does not appear in status, and git add -f forces it in when truly needed."

#git#gitignore#debugging

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.