Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active November 22, 2016 06:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nepsilon/6f2865b4c6392df02e26c02d96795ad7 to your computer and use it in GitHub Desktop.
Save nepsilon/6f2865b4c6392df02e26c02d96795ad7 to your computer and use it in GitHub Desktop.
How to grep search committed code in git? — First published on fullweb.io issue #47

How to grep search committed code in git?

Search working tree for text matching regular expression regexp:

git grep regexp 

Search working tree for lines of text matching regexp A or B:

git grep -e A --or -e B 

Search working tree for lines of text matching regexp A an B:

git grep -e A --and -e B 

Search all revisions between rev1 and rev2 for text matching regular expression regexp:

git grep regexp $(git rev-list rev1..rev2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment