15

How can I find the gitignore file and line that is causing a file to be ignored by git?

idbrii
  • 10,975
  • 5
  • 66
  • 107

1 Answers1

14

From the repo root, try this:

find . ~/.gitignore .git/info/exclude -name '*gitignore' -exec cat {} + | less

Also check that you're not using a different excludes file:

git config -l | grep exclude
core.excludesfile=~/.gitignore

You can also get that error when you have submodules in a subfolder instead at the git project's root.

Thanks to Jon Lin and Christopher for helping me figure this out on the original question.

Community
  • 1
  • 1
idbrii
  • 10,975
  • 5
  • 66
  • 107
  • 1
    The only way I know of to find the line is to binary search. (Remove half the excludes, see if it's still ignored, ...) – idbrii Dec 16 '13 at 22:15
  • In my case the second command found the culprit, it seems like the default version of core.excludesfile ignores 'tags', at least as installed by boxen. This was causing a lot of confusion for us when trying to add new JSTL .tag files. – JBCP Dec 17 '13 at 03:24
  • Saviour! For anyone using Cloud9 IDE, I found you need to go one level up to ~/.gitignore. Because you start off in ~/workspace/, which meant you might not spot the .gitignore. This .gitignore in the home dir had tons of default ignores I did not set, which were causing chaos for me. – redfox05 Dec 09 '15 at 15:32