Use Git Ignore Check to See Why a File Is Ignored
Having Git issues with your file not being detected? Your file might be git ignored. You can use the git check-ignore command to verify if your file is gitnored. It will tell you also which gitignore if you have multiple and which line.
So let’s say we have this directory structure;
So we have a git project with a file all.json
and a .gitignore
in the root. We
also have a directory called js
which also has a .gitignore
in it and a file
call foo.js
. Let’s take a peek at the gitignores:
So, we can see that in the root all.json
is ignored and in the js
directory
we’re ignoring foo.js. Let’s see what happens when we use git check-ignore
The -v
is a verbose flag and gives us the line number and the actual .gitignore
which is useful information to have. This Stackoverflow
answer is a good running commentary from the author who actually implemented the
git check-ignore feature.
Read more about in the git docs