Jason Meridth

Learn, Converse, Share

Use Git Grep to Replace Strings in Files in Your Git Repository

11 February 2013 - San Antonio

TL;DR

git grep -l 'original_text' | xargs sed -i 's/original_text/new_text/g'

I needed to changed a string in a bunch of files and used the command above using git grep to do it. Worked like a charm.

The -l argument to git grep only returns the file names and not the location in the file like it usually does.

Comments