Skip to content

Instantly share code, notes, and snippets.

@amercier
Last active August 29, 2015 13:58
Show Gist options
  • Save amercier/10246387 to your computer and use it in GitHub Desktop.
Save amercier/10246387 to your computer and use it in GitHub Desktop.
bash <(curl -# -L https://gist.github.com/amercier/10246387/raw) <old url> <new url>
#!/usr/bin/env bash
if [ "$1" == "" ] || [ "$2" == "" ]; then
echo "Syntax: $0 <old url> <new url>" 2>&1
exit 1
fi
echo "$1 => $2"
echo "Looking for .git/config files in $(readlink -f .)..."
find . -type f -name config | egrep '/.git/config$' | while read f; do
count=$(grep "$1" "$f" 2>/dev/null | wc -l)
if [ "$count" != "0" ]; then
echo " Found $1 in $f"
cat "$f" | sed -i "s/$(echo $1 | sed 's/\//\\\//g')/$(echo $2 | sed 's/\//\\\//g')/g" "$f"
grep "$2" "$f" >/dev/null 2>&1 && echo " ✔ Patched successfully" || echo " ✘ Failed patching $f"
else
echo " $1 not found in $f"
fi
done
echo Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment