DEV Community

Find A String in a Massive Git Repo

Doug Black on May 08, 2019

Figure I would share this, as I just needed to do this. We have a massive git repo for an Engauge Analytics project we are working on. Tons of the...
Collapse
 
pzelnip profile image
Adam Parkin

You might want to check out the options on the git log command as well, as it can be used to search across all history rather than just all current branches. For example to search all commit messages for the string "foo bar baz":

git log --grep="foo bar baz"
Enter fullscreen mode Exit fullscreen mode

If you want to search file contents, you can use the "pickaxe". Not sure how you do multiple words, but for the single word "foo":

git log -Sfoo
Enter fullscreen mode Exit fullscreen mode

This will search all commits for the word "foo" being added or removed.

Collapse
 
dougblackjr profile image
Doug Black

Awesome! Thank you!

Collapse
 
gahamelan profile image
Haggä

Hi! Great post! I was in need of the same thing. One question, though. Does this search across all branches but also across all commits inside each branch (=the whole repo, at each of the stages)? Thanks.

Collapse
 
mmphego profile image
Mpho Mphego

Nice, just what I needed.
Thanks.

Collapse
 
christopheek profile image
Christophe El-Khoury

So why wouldn't you simply pull that branch locally and search for the string using your IDE / Editor?

Collapse
 
dougblackjr profile image
Doug Black

I want sure what branch the change was in.

Collapse
 
marcospatton profile image
Marcos

great