Last active
September 19, 2024 01:36
-
-
Save helloint/d2896c5c3353f672bae794746340f22f to your computer and use it in GitHub Desktop.
Migrate from GitLab group repos to GitHub orgs in batch
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
# If you have a GitLab group repos that need to migrate to GitHub, currently the best option is to create a GitHub org | |
GITLAB_GROUP_NAME=your_gitlab_group_name | |
GITLAB_DOMAIN=gitlab.com:22 | |
GITHUB_ORG_NAME=your_github_org_name | |
REPOS=("repo_1" "repo_2") | |
for REPO_NAME in ${REPOS[@]}; do | |
git clone --mirror ssh://git@$GITLAB_DOMAIN/$GITLAB_GROUP_NAME/$REPO_NAME.git $REPO_NAME/.git | |
cd $REPO_NAME | |
git config --bool core.bare false | |
git reset --hard | |
# You can rename main branch here if the repo enabled PR process | |
# git branch -m main main2 | |
git remote add target [email protected]:$GITHUB_ORG_NAME/$REPO_NAME.git | |
# If the repo belongs to you, you can automatically create repo using GitHub CLI (See how to setup https://cli.github.com/) | |
# gh repo create $GITHUB_ORG_NAME/$REPO_NAME --private | |
git push --all target | |
git push --tags target | |
cd .. | |
rm -rf $REPO_NAME | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment