Last active
January 25, 2024 23:20
-
-
Save AdamGagorik/1bdb790f26ae64dd82dae7d16af44eca to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
old_url=$(git remote get-url origin) | |
new_url=${old_url//https:\/\//git@} | |
new_url=${new_url//.com\//.com:} | |
echo "old url: $old_url" | |
echo "new url: $new_url" | |
if [[ "${old_url}" == "${new_url}" ]] | |
then | |
echo "Remote url is already in the correct format." | |
exit 0 | |
fi | |
read -p "Are you sure you want to change the remote url? (y/n) " -n 1 -r | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo -e "\nChanging remote url..." | |
git remote set-url origin "${new_url}" | |
else | |
echo -e "\nAborting..." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment