git grep
Mar 11, 2019
git
This is a short note to self about how to use git grep
instead of grep
to find all occurrences of a certain text in all files within a root folder.
I used to use grep
to do this, but always had to lookup the syntax. Also, it’s not as quick and intuitive as I’d like it to be.
However, git grep
is a lot faster and much easier to use than grep
. To use git grep
instead of grep
, you just have to type:
git grep 'the string to search for'
To narrow it down to only search in certain types of files, just add a file pattern:
git grep 'the string to search for' *.txt
This is a lot cleaner and MUCH faster than grep
.