Skip to content

Instantly share code, notes, and snippets.

@Amaimersion
Created February 29, 2024 15:22
Show Gist options
  • Save Amaimersion/676edee098ed686f1baba1ad90fca943 to your computer and use it in GitHub Desktop.
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 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