• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Dev Tips / Why is my file ignored by Git?

Why is my file ignored by Git?

Last updated on August 11, 2024 by Sal Ferrarello

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 (:)

  1. the path from the root of the repo to the first place an ignore pattern appears that applies to the given file
  2. the line number of the ignore pattern
  3. the ignore pattern

Example:

.gitignore:12:vendor/   vendor/bin/phpcs

See git check-ignore documentation.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Computing, Dev Tips, Solution Tagged With: Git, gitignore

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in