git grep

Mar 11, 2019 · Follow on Twitter and Mastodon 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.

Discussions & More

Please share any ideas, feedback or comments you may have in the Disqus section below, or by replying on Twitter or Mastodon..

If you found this text interesting, make sure to follow me on Twitter and Mastodon for more content like this, and to be notified when new content is published.

If you like & want to support my work, please consider sponsoring me on GitHub Sponsors.