Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I search for a string that someone changed with git?

I would like to search for a specific string using git grep but I would like to filter the results by using git blame to know that the string I'm looking for was changed by a specific person.

I just don't know how can I combine them to get the results I want.

Thank you for your help.

like image 714
VaTo Avatar asked Oct 18 '22 21:10

VaTo


1 Answers

You can write a little shell script to accomplish this:

git rev-list --author=Doe HEAD |
while read rev; do
    if git show -p $rev | grep "PATTERN" >/dev/null; then
        echo $rev
    fi
done

This will output the SHA's that are reachable by HEAD that have an author of "Doe" and have "PATTERN" in the commit content's.

like image 91
Jonathan.Brink Avatar answered Oct 21 '22 22:10

Jonathan.Brink