Created
May 7, 2013 19:10
-
-
Save DavidYKay/5535253 to your computer and use it in GitHub Desktop.
Git search and replace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#~/.scripts/git-sub | |
#Author: Khaja Minhajuddin <[email protected]> | |
#script which does a global search and replace in the git repository | |
#it takes two arguments | |
#e.g. git sub OLD NEW | |
old=$1 | |
new=$2 | |
for file in $(git grep $old | cut -d':' -f 1 | uniq) | |
do | |
echo "replacing '$old' with '$new' in '$file'" | |
sed -i -e "s/$old/$new/g" $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment