git grep

Mar 11, 2019 · Follow on Twitter and Mastodon git

This is a short note to my future self on how to use git grep instead of grep to find all occurrences of a certain text in all files within a git repository folder.

I used to use grep to achieve this, but always had to lookup the syntax. Also, it’s not as quick and intuitive as I’d like it to be. git grep is a LOT faster, and much easier to use.

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 easier to use, 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.