This document explains how to migrate a repository from GitLab to GitHub. This procedure assumes you:
- have set up a GitHub account.
- are a member of the GitHub organization and can create new reports.
- have owner-level access to the GitLab repository that will be migrated.
Initiate the Migration Process
- Login to GitHub.
- Click the profile icon (upper right), and click Your Organization.
- Click the Repositories tab.
- Click New repository.
- Click Import a repository.
- Enter the GitLab repository URL in the Your old repository's clone URL field.
- Enter the organization in the Owner field.
- Enter the GitHub Repository Name.
- Select a Privacy level.
- Click Begin import.
Note The import process will fail and then prompt you for credentials (unless the GitLab repository is public). Leave the Login form open and continue to step 11.
- Open a new browser window and navigate to the GitLab repository you are importing.
- In your GitLab repository, hover over the Settings icon and select Repository.
- Under the Deploy Tokens section, click Expand.
- Enter importer in the Name and Username fields.
- Enter a date two days in the future in the Expiration date field.
- Check the read_repository, read_registry, and read_package_registry boxes.
- Click Create deploy token.
- Click the Clipboard icon next to the Token field to copy it to your clipboard.
- Navigate back to the GitHub browser window.
- Enter importer in the Login field.
- Paste the token in the Password field.
- Click Submit.
Post-Migration GitHub Configuration
After the repository has successfully imported from GitLab to GitHub, use the Settings tab of your GitHub repository to configure the following as appropriate:
- Collaborators and teams
- Branches - Set a default branch and branch rules (e.g., it is common to require a pull request before merging)
- Deploy keys - but note that GitHub only allows an SSH keypair to be used once system wide
- And anything else your developers require
Remind developers to update any local references on their workstations by navigating to the repository and setting the new remote URL:
# Confirm the new remote setting
git remote -v
Finally, any automation (batch jobs, CI/CD pipelines) need to be updated to use the GitHub repository.
Post-Migration GitLab Cleanup
NB: Archiving your GitLab repository may be a good idea in order to prevent accidental commits.
Note Get buy-in from your team before proceeding as this changes the repository to read-only.
After getting buy-in, and after the repository has successfully migrated from GitLab to GitHub:
- In your GitLab repository, hover over the Settings icon and click General.
- Under the Advanced section, click Expand.
- Under the Archive project section, click Archive project.