Regexp search Git repo history and output the file contents.

git grep <regexp> $(git rev-list --all)


git rev-list --all | xargs git grep "regexp"

if previous line gives you ‘Argument list too long’
To show file contents.

git show <SHA> -- <path-to-file>

credits go to SO.

To find the commit when the given line was first introuduced use:

git log -S  	
# or
git log -G 

Leave a Reply

Your email address will not be published. Required fields are marked *