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:¶
-
Mac: brew install gh Linux: See instructions at https://github.com/cli/cli/blob/trunk/docs/install_linux.md -
Python 3, python-gitlab and python-csv
python3 -m pip install python-gitlab python-csv -
JSON processor,
jqMac: brew install jq Ubuntu: apt install jq Fedora: dnf install jq openSuSE: zypper install jq More information: Visit https://jqlang.org/download/ -
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"- By default, this extracts data from http://git-acad.njit.edu. If you want to extract data from another site, say https://gitlab.com, then add
--url https://gitlab.com
- By default, this extracts data from http://git-acad.njit.edu. If you want to extract data from another site, say https://gitlab.com, then add
-
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
and use the path output in the previous 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}]'
Known Issues¶
- If your repo on gitlab uses LFS, the
git push --mirrorcommand in theimport_to_github.shscript will fail. You might need to clone the repo and track large files with lfs before pushing to github. - Issues, merge requests, milestones etc will be under your gitlab account i.e. njit ucid not your github handle.