Created
April 23, 2022 08:52
-
-
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
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
#/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