2020-10-23 20:08:35 -04:00
---
2020-12-01 13:09:42 -05:00
stage: Enablement
group: Distribution
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-10-23 20:08:35 -04:00
---
2021-01-28 01:08:59 -05:00
# GitHub import **(FREE SELF)**
2017-04-06 08:47:40 -04:00
2020-02-06 10:09:11 -05:00
> [Introduced]( https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/10308) in GitLab 9.1.
2018-10-09 09:06:29 -04:00
2020-10-02 17:08:18 -04:00
To retrieve and import GitHub repositories, you need a [GitHub personal access token ](https://github.com/settings/tokens ).
A username should be passed as the second argument to the Rake task,
2020-11-19 16:09:07 -05:00
which becomes the owner of the project. You can resume an import
2018-10-09 09:06:29 -04:00
with the same command.
Bear in mind that the syntax is very specific. Remove any spaces within the argument block and
2020-04-27 02:09:51 -04:00
before/after the brackets. Also, some shells (for example, `zsh` ) can interpret the open/close brackets
2018-10-09 09:06:29 -04:00
(`[]`) separately. You may need to either escape the brackets or use double quotes.
2020-05-28 14:08:37 -04:00
## Caveats
2021-02-18 19:11:06 -05:00
If the GitHub [rate limit ](https://docs.github.com/en/rest/reference/rate-limit ) is reached while
importing, the importing process waits (`sleep()`) until it can continue importing.
2020-05-28 14:08:37 -04:00
2018-10-09 09:06:29 -04:00
## Importing multiple projects
2017-04-06 08:47:40 -04:00
To import a project from the list of your GitHub projects available:
2020-01-30 10:09:15 -05:00
```shell
2017-04-06 08:47:40 -04:00
# Omnibus installations
2018-10-09 09:06:29 -04:00
sudo gitlab-rake "import:github[access_token,root,foo/bar]"
2017-04-06 08:47:40 -04:00
# Installations from source
2018-10-09 09:06:29 -04:00
bundle exec rake "import:github[access_token,root,foo/bar]" RAILS_ENV=production
2017-04-06 08:47:40 -04:00
```
In this case, `access_token` is your GitHub personal access token, `root`
2020-11-19 16:09:07 -05:00
is your GitLab username, and `foo/bar` is the new GitLab namespace/project
created from your GitHub project. Subgroups are also possible: `foo/foo/bar` .
2017-04-06 08:47:40 -04:00
2018-10-09 09:06:29 -04:00
## Importing a single project
2017-04-06 08:47:40 -04:00
To import a specific GitHub project (named `foo/github_repo` here):
2020-01-30 10:09:15 -05:00
```shell
2017-04-06 08:47:40 -04:00
# Omnibus installations
2018-10-09 09:06:29 -04:00
sudo gitlab-rake "import:github[access_token,root,foo/bar,foo/github_repo]"
2017-04-06 08:47:40 -04:00
# Installations from source
2018-10-09 09:06:29 -04:00
bundle exec rake "import:github[access_token,root,foo/bar,foo/github_repo]" RAILS_ENV=production
2018-03-06 15:21:56 -05:00
```