I love git grep
to search in all files checked in to a repo. 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
.
Any ideas for clever tricks?
Usage. While browsing your Git repository, start typing in the path control box to search for the file or folder you are looking for. The interface lists the results starting from your current folder followed by matching items from across the repo.
Git ships with a command called grep that allows you to easily search through any committed tree, the working directory, or even the index for a string or regular expression. For the examples that follow, we'll search through the source code for Git itself.
You can search for a file in a repository using the file finder. To search for a file in multiple repositories on GitHub, use the filename code search qualifier.
To be sure that you are using the Unix find from the Git Bash shell, type /bin/find . Now the -name parameter will work as shown in other answers. I'm using git for Windows and find .
Maybe you want git ls-files
which lists the files in the index? (and automatically adjusts for your current directory inside the git work directory)
I think git ls-files
will do the trick for you.
So:
git ls-files "*middleware*"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With