Introduced in GitLab 15.8, GitLab no longer automatically creates namespaces or groups that don’t exist. GitLab also no longer falls back to using the user’s personal namespace if the namespace or group name is taken.
You can import your GitHub projects from either GitHub.com or GitHub Enterprise. Importing projects does not migrate or import any types of groups or organizations from GitHub to GitLab.
The namespace is a user or group in GitLab, such as
gitlab.com/sidney-jones
or
gitlab.com/customer-success
. You can use bulk actions in the rails console to move projects to
different namespaces.
If you are importing to a self-managed GitLab instance, you can use the GitHub Rake task instead. This allows you to import projects without the constraints of a Sidekiq worker.
When importing projects:
GH-SHA-username/pull-request-number/fork-name/branch
. This may lead to
a discrepancy in branches compared to those of the GitHub repository.
For an overview of the import process, see Migrating from GitHub to GitLab .
To import projects from GitHub:
Each GitHub author and assignee in the repository must have a public-facing email address on GitHub that matches their GitLab email address (regardless of how the account was created). If their email address from GitHub is set as their secondary email address in GitLab, they must confirm it.
When issues and pull requests are being imported, the importer attempts to find their GitHub authors and assignees in the database of the GitLab instance. Pull requests are called merge requests in GitLab. For the importer to succeed, matching email addresses are required.
See also Branch protection rules and project settings for additional prerequisites for those imports.
If you are importing from GitHub Enterprise to a self-managed GitLab instance:
github.com
and
api.github.com
to solve the hostname. For more information, read the issue
Importing a GitHub project requires DNS resolution even when behind a proxy
.
If you are importing from GitHub.com to a self-managed GitLab instance:
Before you begin, ensure that any GitHub user you want to map to a GitLab user has a GitLab email address that matches their publicly visible email address on GitHub.
If you are importing to GitLab.com, you can alternatively import GitHub repositories using a personal access token .
If a GitHub user’s public email address doesn’t match any GitLab user email address, the user’s activity is associated with the user account that is performing the import.
If you are a GitLab.com user, you can use a personal access token to import your project from GitHub. If you are an administrator of a self-managed GitLab instance or if you are importing from GitHub Enterprise, you cannot use a personal access token. The GitHub integration method (above) is recommended for all users.
If you are not using the GitHub integration, you can still perform an authorization with GitHub to grant GitLab access your repositories:
To use a newer personal access token in imports after previously performing these steps, sign out of your GitLab account and sign in again, or revoke the older personal access token in GitHub.
Introduced in GitLab 15.5.
To make imports as fast as possible, the following items aren’t imported from GitHub by default:
You can choose to import these items, but this could significantly increase import time. To import these items, select the appropriate fields in the UI:
After you have authorized access to your GitHub repositories, you are redirected to the GitHub importer page and your GitHub repositories are listed.
By default, the proposed repository namespaces match the names as they exist in GitHub, but based on your permissions, you can choose to edit these names before you proceed to import any of them.
To select which repositories to import, next to any number of repositories select Import or select Import all repositories .
Additionally, you can filter projects by name. If a filter is applied, Import all repositories only imports matched repositories.
The Status column shows the import status of each repository. You can choose to keep the page open and watch updates in real time or you can return to it later.
To cancel imports that are pending or in progress, next to the imported project, select Cancel . If the import has already started, the imported files are kept.
To open an repository in GitLab URL after it has been imported, select its GitLab path.
Completed imports can be re-imported by selecting Re-import and specifying new name. This creates a new copy of the source project.
Depending on your GitLab tier, repository mirroring can be set up to keep your imported repository in sync with its GitHub copy.
Additionally, you can configure GitLab to send pipeline status updates back to GitHub with the GitHub Project Integration .
If you import your project using CI/CD for external repository , then both of the above are automatically configured.
Administrator access on the GitLab server is required for this process.
The following items of a project are imported:
All attachment imports are disabled by default behind
github_importer_attachments_import
feature flag
. From GitLab 15.5, can
be imported
as an additional item
. The feature flag was removed.
github_importer_issue_events_import
feature flag
disabled by default.
From GitLab 15.5, can be imported
as an additional item
. The feature flag was
removed.
References to pull requests and issues are preserved. Each imported repository maintains visibility level unless that visibility level is restricted , in which case it defaults to the default project visibility.
When they are imported, supported GitHub branch protection rules are mapped to either:
Require conversation resolution before merging for the project’s default branch Require signed commits for the project’s default branch Require a pull request before merging - Allow specified actors to bypass required pull requests (1)| GitHub rule | GitLab rule | Introduced in |
|---|---|---|
| All threads must be resolved project setting | GitLab 15.5 | |
| Require a pull request before merging | No one option in the Allowed to push list of branch protection settings | GitLab 15.5 |
| Reject unsigned commits GitLab push rule | GitLab 15.5 | |
| Allow force pushes - Everyone | Allowed to force push branch protection setting | GitLab 15.6 |
| Require a pull request before merging - Require review from Code Owners | Require approval from code owners branch protection setting | GitLab 15.6 |
| List of users in the Allowed to push list of branch protection settings . Without a Premium license, the list of users that are allowed to push is limited to roles. | GitLab 15.8 |
Mapping GitHub rule Require status checks to pass before merging to external status checks was considered in issue 370948 . However, this rule is not imported during project import into GitLab due to technical difficulties. You can still create external status checks manually.
Introduced in GitLab 15.10.
These GitHub collaborator roles are mapped to these GitLab member roles :
| GitHub role | Mapped GitLab role |
|---|---|
| Read | Guest |
| Triage | Reporter |
| Write | Developer |
| Maintain | Maintainer |
| Admin | Owner |
GitHub Enterprise Cloud has custom repository roles . These roles aren’t supported and cause partially completed imports.
To import GitHub collaborators, you must have at least the Write role on the GitHub project. Otherwise collaborators import is skipped.
GitHub API uses the
Link
header for pagination.
Also test that cloning the repository using the proxy does not fail:
The following configuration is an example on how to configure Apache HTTP Server as a reverse proxy
# Required modules
LoadModule filter_module lib/httpd/modules/mod_filter.so
LoadModule reflector_module lib/httpd/modules/mod_reflector.so
LoadModule substitute_module lib/httpd/modules/mod_substitute.so
LoadModule deflate_module lib/httpd/modules/mod_deflate.so
LoadModule headers_module lib/httpd/modules/mod_headers.so
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_connect_module lib/httpd/modules/mod_proxy_connect.so
LoadModule proxy_http_module lib/httpd/modules/mod_proxy_http.so
LoadModule ssl_module lib/httpd/modules/mod_ssl.so
<VirtualHost GITHUB_ENTERPRISE_HOSTNAME:80>
ServerName GITHUB_ENTERPRISE_HOSTNAME
# Enables reverse-proxy configuration with SSL support
SSLProxyEngine On
ProxyPass "/" "https://GITHUB_ENTERPRISE_HOSTNAME/"
ProxyPassReverse "/" "https://GITHUB_ENTERPRISE_HOSTNAME/"
# Replaces occurrences of the local GitHub Enterprise URL with the Proxy URL
# GitHub Enterprise compresses the responses, the filters INFLATE and DEFLATE needs to be used to
# decompress and compress the response back
AddOutputFilterByType INFLATE;SUBSTITUTE;DEFLATE application/json
Substitute "s|https://GITHUB_ENTERPRISE_HOSTNAME|https://PROXY_HOSTNAME|ni"
SubstituteMaxLineLength 50M
# GitHub API uses the response header "Link" for the API pagination
# For example:
# <https://example.com/api/v3/repositories/1/issues?page=2>; rel="next", <https://example.com/api/v3/repositories/1/issues?page=3>; rel="last"
# The directive below replaces all occurrences of the GitHub Enterprise URL with the Proxy URL if the
# response header Link is present
Header edit* Link "https://GITHUB_ENTERPRISE_HOSTNAME" "https://PROXY_HOSTNAME"
</VirtualHost>
For information on automating user, group, and project import API calls, see Automate group and project import .
The GitHub importer might encounter some errors when importing large projects.
If it’s not possible to fetch all pages, the GitHub API might return the following error:
An alternative approach for importing comments is available.
Instead of using
issues_comments
and
pull_requests_comments
, use individual resources to pull notes from one object at a time. This way, you can carry over any missing comments. However, execution takes longer because this method increases the number of network requests required to perform the import.
Run the following
enable
command:
group = Group.find_by_full_path('my/group/fullpath')
# Enable
Feature.enable(:github_importer_lower_per_page_limit, group)
To disable the feature flag, run this command:
# Disable
Feature.disable(:github_importer_lower_per_page_limit, group)
Docs
Edit this page
to fix an error or add an improvement in a merge request.
Create an issue
to suggest an improvement to this page.
Product
Create an issue
if there's something you don't like about this feature.
Propose functionality
by submitting a feature request.
Join First Look
to help shape new features.
Feature availability and product trials
View pricing
to see all GitLab tiers and features, or to upgrade.
Try GitLab for free
with access to all features for 30 days.
Get Help
If you didn't find what you were looking for,
search the docs.
If you want help with something specific and could use community support,
post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab
subscription).
Request support