Debugging gitignore rules

Have you wondered why a file or directory is being ignored in your Git repository and isn't appearing when you run git status?

Maybe you have multiple .gitignore files and you don't know which is causing the issue, or you ignore everything and explicitly unignore the files that you want to add.

check-ignore to the rescue

git check-ignore accepts a list of paths and checks if each is ignored.

There's also a --verbose option that will tell you which .gitignore file is causing it to be ignored as well as the line number and the pattern - great information for debugging, and no more force adding files.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.