When we were migrating from Gitlab to Github, I found out that there wasn’t an easy way to import everything from Gitlab to Github, as Github doesn’t offer a good tool for that, so I ended up writing the small script below and hosted it as a gist if anyone finds this useful.



# 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"

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