Skip to content

Instantly share code, notes, and snippets.

@katzefudder
Created July 25, 2019 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katzefudder/0007dd44fea432ac75d55d88b74b8fdd to your computer and use it in GitHub Desktop.
Save katzefudder/0007dd44fea432ac75d55d88b74b8fdd to your computer and use it in GitHub Desktop.
Changing upstream from Gitlab to Bitbucket (migration)
#!/bin/bash
function changeUpstream() {
cd /tmp && git clone --quiet $1
basename=$(basename $1)
dirname=${basename%.*}
cd $dirname
clear
echo "###### You are about to execute the following commands on $basename ######"
command1="git remote set-url origin $2"
command2="git push -u origin master"
echo $command1
echo $command2
echo '###### ------------------------------------------------ ######'
read -r -p "Are you sure (y,n) ?" response
case "$response" in
[yY][eE][sS]|[yY])
echo $command1
echo $command2
#eval $command1 > /dev/null 2>&1
#eval $command2 > /dev/null 2>&1
;;
*)
echo 'exiting...'
;;
esac
rm -Rf /tmp/$dirname
}
echo '###### Migration from GitLab to Bitbucket'
read -p "Enter your GitLab Repository: " gitLabRepo
read -p "Enter your Bitbucket Repository: " bitbucketRepo
changeUpstream $gitLabRepo $bitbucketRepo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment