Created
April 18, 2020 10:39
-
-
Save bzamecnik/ee4caf2a02b5a004f9a51231986b2663 to your computer and use it in GitHub Desktop.
Rename Git remotes to new domain
This file contains 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
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