Skip to content

Instantly share code, notes, and snippets.

@AdamGagorik
Last active January 25, 2024 23:20
Show Gist options
  • Save AdamGagorik/1bdb790f26ae64dd82dae7d16af44eca to your computer and use it in GitHub Desktop.
Save AdamGagorik/1bdb790f26ae64dd82dae7d16af44eca to your computer and use it in GitHub Desktop.
#!/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