Created
February 29, 2024 15:22
-
-
Save Amaimersion/676edee098ed686f1baba1ad90fca943 to your computer and use it in GitHub Desktop.
Bash script to migrate all repositories from GitHub organization to GitLab group
This file contains hidden or 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
# This script migrates all repositories from GitHub organization to GitLab group. | |
# | |
# Prerequisites: | |
# - Linux | |
# - install Git | |
# - install and auth GitHub CLI | |
# - install and auth GitLab CLI | |
# - create target GitLab group | |
# | |
# Limitations: | |
# - 4000 GitHub repos at max | |
# - only master branch, tags and description | |
# - all cloned repos will be private | |
# When you done, manually remove this folder | |
mkdir clone | |
cd clone | |
# Replace GH_ORG with org name | |
gh repo list GH_ORG --limit 4000 | while read -r repo _; do | |
gh repo clone "$repo" "$repo" | |
done | |
cd GH_ORG | |
# Replace GL_GROUP with group name | |
ls | xargs -I {} bash -c 'cd {} && glab repo create --private --group GL_GROUP --remoteName clone --description "$(gh repo view --json description --jq .description)" && git push clone && git push clone --tags' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment