grep - global regular expressions

 

Search for text in your work tree under source control.

This lists all matched lines for files ONLY in source control.

git grep -e 'e' -- '*.txt'

 

This lists all matched lines including items in staging

git grep --cached 'some_phrase' -- '*.txt'

git grep <regexp>

 

git grep -e 'gr[e|a]y' | more

 

<regexp> http://en.wikipedia.org/wiki/Regular_expression


List lines that contain Jonny and rockets

git grep -l -e jonny --and -e rockets

 


Ignore Case

-i

--ignore-case

 

grep -i "foo" foobar.txt


Must appear at the start of the line

grep "^foobar" myfile.txt