Skip to content

Instantly share code, notes, and snippets.

@ViacheslavK
Created June 20, 2022 23:35
Show Gist options
  • Save ViacheslavK/f1a515b6fb5c6395d4ce4b32d3ff55e4 to your computer and use it in GitHub Desktop.
Save ViacheslavK/f1a515b6fb5c6395d4ce4b32d3ff55e4 to your computer and use it in GitHub Desktop.
bash script for changing remote origin URL if -r option set as 1 or 2
#!/bin/sh
sgit=git@gitlab.com:user/repo.git
ggit=git@github.com:user/repo.git
while getopts r: flag
do
case "${flag}" in
r) remote_git=${OPTARG};;
esac
done
case $remote_git in
1)
git remote set-url --push origin $sgit
git remote set-url --add origin $sgit
git remote set-url --delete origin $ggit
;;
2)
git remote set-url --push origin $ggit
git remote set-url --add origin $ggit
git remote set-url --delete origin $sgit
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment