Jason Meridth published a wonderful one-liner back in 2013, for replacing a string that occurs anywhere within a repo. I find myself using it often, but not often enough to memorize it, so I’m shamelessly duplicating it here for posterity.
git grep -l 'original_text' | xargs sed -i 's/original_text/new_text/g'
git grep -l 'original_text' | xargs sed -i '' -e 's/original_text/new_text/g'
git greponly returns the file names and not the location in the file like it usually does.
-eargument is needed with the
sedportion on OSX.