Skip to content

Instantly share code, notes, and snippets.

@ebourgess
Created April 23, 2022 08:52
Show Gist options
  • Save ebourgess/ff4d553b55e96b358b7fa1ddc3033ba7 to your computer and use it in GitHub Desktop.
Save ebourgess/ff4d553b55e96b358b7fa1ddc3033ba7 to your computer and use it in GitHub Desktop.
This is a script that migrates all tags and branches from Gitlab to Github
#/bin/sh
DIR=$1
OLDREPO=$2
NEWREPO=$3
# clone the old repository and navigate into the new directory
git clone $OLDREPO $DIR
cd $DIR
# check out all of the remote branches locally
git branch --remotes --no-color | grep --invert-match "\->" | while read remote; do
git checkout --track "$remote"
done
git checkout master
# set new origin remote url
git remote set-url origin $NEWREPO
# push all branches and tags to the new remote url
git push --mirror $NEWREPO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment