Search code examples
gitgitignore

Get a list of all gitignore files in my current branch, unrelated to their tracking or modification state


I asked this question already again, but it was closed prematurely, since the given link did not answer my question as explained. I have a Git repo and would like to get a list of files, which are ignored by Git in my current branch, and those which are not, unrelated to if they are tracked, or not, or what their state is.

I found git-check-ignore, but my repository has a few thousand files, and checking it on a per file basis takes simply too long to spawn a process for each file.

git check-ignore /file/to/foo

Does Git have another command that allows me to get a list of files which are ignored by git?


Solution

  • I think the command you're looking for is git ls-files -ioc --exclude-standard. That command will list files using the standard exclude paths that are either tracked (in the index) or untracked.

    Even if that's not the exact invocation that you're looking for, git ls-files is the tool which is most likely to give you an efficient answer. It also has the -z option which is useful for odd filenames and scripting use.