Skip to content

Instantly share code, notes, and snippets.

@bzamecnik
Created April 18, 2020 10:39
Show Gist options
  • Save bzamecnik/ee4caf2a02b5a004f9a51231986b2663 to your computer and use it in GitHub Desktop.
Save bzamecnik/ee4caf2a02b5a004f9a51231986b2663 to your computer and use it in GitHub Desktop.
Rename Git remotes to new domain
for remote in $(git remote); do
old_url=$(git remote get-url "$remote")
new_url=${old_url//git.old.example.com/git.new.example.com}
if [ "$old_url" != "$new_url" ]; then
echo "$remote: $old_url -> $new_url"
git remote set-url "$remote" "$new_url"
else
echo "$remote: $old_url (already OK)"
fi
done
git remote -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment