Search code examples
gitgrep

How can I 'grep' files in a Git repository?


I love git grep to search in all files checked in to a repository. It's great. But is it possible to use it (or some other Git command) to just use to find files (independent of content)?

At the moment I do this:

find . | grep middleware

which works, but it's not using the Git index which means it's going through every found file and it reports on files that are matching the .gitignore.

Are there some clever tricks?


Solution

  • You may want git ls-files which lists the files in the index (and automatically adjusts for your current directory inside the Git work directory).