Skip to content
gitrep
Library

3e18b52snippet1 min read

Find and replace across a repository

A safe one-liner with ripgrep and sed, with a dry run first.

Published

Preview every match first, then apply the change only to files that contain it.

sh
rg -n 'oldName'
sh
rg -l 'oldName' | xargs sed -i '' 's/oldName/newName/g'   # macOS
rg -l 'oldName' | xargs sed -i 's/oldName/newName/g'      # Linux
  1. Interactive rebase without fearSquash, reorder, and reword commits before review, with a safety net in place.Guide