Skip to content

Gitlab 2 Github Migration

The following instructions were developed for migrating repositories with their issues, merge requests, milestones and notes (i.e. issue and merge request comments) from self managed on premise gitlab server for academic use to github enterprise cloud, njit-academics organization, on Mac OSX 15.5. It has also been tested on a Ubuntu 24.04 LTS virtual image. It should work for migration from other gitlab servers to other github organizations on other OS's.

Requirements:

  1. Personal Access Tokens for gitlab and github

  2. Github CLI

    Mac: brew install gh
    Linux: See instructions at https://github.com/cli/cli/blob/trunk/docs/install_linux.md 
    

  3. Python 3, python-gitlab and python-csv

    python3 -m pip install python-gitlab python-csv
    

  4. JSON processor, jq

    Mac: brew install jq
    Ubuntu: apt install jq
    Fedora: dnf install jq
    openSuSE: zypper install jq
    More information: Visit https://jqlang.org/download/
    

  5. Optional: Consider setting up Connecting to Github with SSH. If you haven't or prefer not to, see note in migration step below.

Migration steps

  • Download the python and bash script.

    These scripts were developed on Microsoft Co-pilot based on input specific to repositories on the academic gitlab server and njit-academics organization.

  • Extract all gitlab repo data that you have access to

    python3 export_all_gitlab_repos.py --token "gitlab token"
    

  • Import repository to your github team

    bash import_to_github.sh "your team name"
    

    • NOTE: If you do not plan on using ssh keys, comment out line 39 and uncomment line 40. You will be prompted for your github username and password. Enter your Github Personal Access Token from step 1 above for password.
    • To find "your team name", you can run the command
      gh api \
         -H "Accept: application/vnd.github+json" \
         -H "X-GitHub-Api-Version: 2022-11-28" \
         /orgs/njit-academics/teams | \
         jq -c '[.[] | {name: .name, path: .slug, description: .description}]'
      
      and use the path output in the previous command.

Known Issues

  1. If your repo on gitlab uses LFS, the git push --mirror command in the import_to_github.sh script will fail. You might need to clone the repo and track large files with lfs before pushing to github.
  2. Issues, merge requests, milestones etc will be under your gitlab account i.e. njit ucid not your github handle.