9

Is there a way to move an entire repository from Github to GitLab?

For the code itself, this would be a simple matter of creating a new repo on GitLab and pushing to it.

Wiki pages live in a separate branch on Github and are managed with Git mechanisms; AFAIK the same goes for GitLab. Same story for pages.

That leaves issues and merge requests as the main open points. Is there a way to copy those from Github to GitLab, at least in the state they were in at the time of the migration?

Github offers an export ferature, and GitLab has an import feature which can import a Github repository—do any of these help with the above?

1

3 Answers 3

12

GitLab’s import feature has worked quite nicely.

  • On https://gitlab.com (make sure you are logged in), you will get a list of your projects. Click New Project.
  • Open the Import Project tab, and click Github.
  • If you have not granted Gitlab authorization to access your Github account, you will be prompted to do so now.
  • A list of your Github repos will appear. For each repo you wish to import, choose the namespace (your personal one or that of any of your organizations, if any) and change the project name if you wish. (Default is to import to your personal namespace and use the same repo name as on Github.) Then click Import next to the repo you wish to import.

Import will take a couple of minutes. When it finishes, you will get your entire repo, including wiki, issues and merge requests. Issues and merge requests will retain ticket numbers as on Github, and labels also seem to get migrated.

Github Pages do not seem to get migrated automatically. This requires some manual steps. For purely static content (no SSG), with content stored in the gh-pages branch, the process is as follows:

  • Switch to your gh-pages branch.
  • Create a new folder public and move all content there.
  • Commit your changes.
  • Switch back to master and merge gh-pages (so that your content now resides on a separate folder in master rather than its own branch).
  • On your project’s main page, click Add CI/CD. This will create a new .gitlab-ci.yml file; add the following content and commit:
image: alpine:latest

pages:
  stage: deploy
  script:
  - echo 'Nothing to do...'
  artifacts:
    paths:
    - public
  only:
  - master

This will take another few minutes. Navigate to Settings > Pages and click the link to your pages.

Github has multiple options for storing web content; the above may also work for others with slight modifications.

4

According to the official docs, the following aspects of a project are imported when importing from GitHub to GitLab:

  • Repository description (GitLab.com & 7.7+)
  • Git repository data (GitLab.com & 7.7+)
  • Issues (GitLab.com & 7.7+)
  • Pull requests (GitLab.com & 8.4+)
  • Wiki pages (GitLab.com & 8.4+)
  • Milestones (GitLab.com & 8.7+)
  • Labels (GitLab.com & 8.7+)
  • Release note descriptions (GitLab.com & 8.12+)
  • Pull request review comments (GitLab.com & 10.2+)
  • Regular issue and pull request comments
0

That leaves issues and merge requests as the main open points. Is there a way to copy those from Github to GitLab, at least in the state they were in at the time of the migration?

GitLab 15.5 (October 2022) might help:

Import and store attachments when importing from GitHub

You can now import GitHub project image resources and other attachment types from release notes and comments. The attachments are added to GitLab and their links are updated to new GitLab URLs.

Attachments aren’t imported by default because it can be a time intensive operation. To import them, go to the GitHub import page, and select Import Markdown attachments under Advanced import settings when importing using the GitLab UI.

See Documentation and Issue.

And:

Import more relationships when importing projects from GitHub

Importing all supported relationships during a project import from GitHub can take a long time and is disabled by default. Specifically:

Now you can include these additional relationships in an import if you require them, which slows down the import but includes more information.
To import additional relationships, go to the GitHub import page and select appropriate checkboxes under Advanced import settings.

https://about.gitlab.com/images/15_5/import-more-relationships-from-github.png -- Import more relationships when importing projects from GitHub

See Documentation and Issue.

With:

Import pull request and issue events from GitHub

We continue to improve the GitHub project importer by adding more metadata to the migrated projects.
With added pull request events history, the following pull request events can be imported from GitHub and become part of a merge request’s metadata:

  • Closed or reopened.
  • Labeled or unlabeled.
  • Review requested or review request removed.
  • Assigned or unassigned.
  • Edited.

With added issue events history, the following issue events can be imported from GitHub and become part of an issue’s metadata:

  • Closed or reopened.
  • Labeled or unlabeled.
  • Milestone added or removed.
  • Cross-referenced.
  • Assigned or unassigned.
  • Renamed.

Because importing pull request and issue events can take a long time, they aren’t imported by default.
To import them, go to the GitHub import page, and select Import issue and pull request events under Advanced import settings when importing using the GitLab UI.

See Epic 7673, Epic 7655 and
Documentation.

Not the answer you're looking for? Browse other questions tagged or ask your own question.