# Migrate your repositories from GitLab to GitHub

Perform a trial run and then migrate your repositories from GitLab to GitHub.

## Prerequisites

* You must have completed all previous phases of this guide.
* The GitLab project must be enabled for exports. See [Enable project export](https://docs.gitlab.com/administration/settings/import_and_export_settings/#enable-project-export) and [Sidekiq configuration for imports](https://docs.gitlab.com/administration/sidekiq/configuration_for_imports/) in the GitLab documentation.
* Certifique-se de entender os dados que serão migrados e as limitações de suporte conhecidas do Importador. For more information, see [Understand migrations from GitLab to GitHub](/pt/migrations/using-github-enterprise-importer/migrate-from-gitlab/understand-migrations).
* Embora não seja necessário, recomendamos interromper o trabalho durante a migração de produção. O Importer não dá suporte a migrações delta, ou seja, as alterações que ocorrerem durante a migração não serão migradas. Se você optar por não interromper o trabalho durante a migração de produção, precisará migrar manualmente essas alterações.

## Performing a trial run

Para ajudar a descobrir problemas que podem ser exclusivos da sua empresa, é altamente recomendável realizar um teste de migração. Com uma versão de teste, você aprenderá:

* Se a migração para um determinado repositório pode ser concluída com êxito.
* Se você pode obter o repositório migrado de volta para um estado viável.
* Quanto tempo uma migração levará para ser executada.

Testes práticos podem ocorrer a qualquer momento, e o trabalho não precisa ser interrompido durante a migração. Para reduzir o tempo necessário para concluir suas migrações de teste, você pode agendar os lotes para suas execuções de teste uma após a outra. Os usuários desses repositórios podem validar os resultados no seu próprio tempo.

1. Create a test organization for your trial migrations.

   You can use a single organization for all trial runs, or you can create one test organization for each intended destination organization. Consider including `-sandbox` at the end of the organization names, to clarify that the organizations are intended only for migration validation and not for production. You can delete the test organizations after you're done.

2. Run the trial migrations.

3. Confirm that you are able to complete the follow-up tasks in [Follow-up tasks](/pt/migrations/using-github-enterprise-importer/migrate-from-gitlab/follow-up-tasks).

4. Ask users to validate the results of the migrations.

5. Resolve any issues uncovered by your trial migrations.

6. Opcionalmente, exclua a organização de teste.

## Migrating a single repository

To migrate one repository, use the `gh gl2gh migrate-repo` command.

```shell copy
gh gl2gh migrate-repo \
  --gitlab-server-url GITLAB_SERVER_URL \
  --gitlab-group SOURCE_GROUP \
  --gitlab-project SOURCE_PROJECT \
  --github-org DESTINATION \
  --github-repo NEW_REPO_NAME \
  --use-github-storage
```

Replace the placeholders in the command above with the following values.

| Placeholder         | Value                                                                                                                                        |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| GITLAB\_SERVER\_URL | The full URL of your GitLab instance, such as `https://gitlab.com` or `https://gitlab.example.com`.                                          |
| SOURCE\_GROUP       | The full path of the group or namespace that contains the project. For nested subgroups, use the full path, such as `parent-group/subgroup`. |
| SOURCE\_PROJECT     | The GitLab project to migrate.                                                                                                               |
| DESTINATION         | The destination organization on GitHub.                                                                                                      |
| NEW\_REPO\_NAME     | The name for the repository on GitHub.                                                                                                       |

If you are not using GitHub-owned blob storage, see [Configure blob storage](/pt/migrations/using-github-enterprise-importer/migrate-from-gitlab/configure-storage).

### Additional arguments

| Argument                                  | Description                                                                                                                                                                                                                                                                                                   |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--target-repo-visibility`                | Sets the visibility of the new repository to `public`, `private`, or `internal`. Defaults to `private`.                                                                                                                                                                                                       |
| `--target-api-url TARGET-API-URL`         | Se você estiver migrando para o GHE.com, adicione `--target-api-url TARGET-API-URL`, em que TARGET-API-URL é a URL da API base para o subdomínio da sua empresa. Por exemplo: `https://api.octocorp.ghe.com`.                                                                                                 |
| `--target-uploads-url TARGET-UPLOADS-URL` | If you're migrating to GHE.com and using GitHub-owned blob storage, also add `--target-uploads-url TARGET-UPLOADS-URL`, where TARGET-UPLOADS-URL is the base uploads API URL for your enterprise's subdomain. For example: `https://uploads.octocorp.ghe.com`. This defaults to `https://uploads.github.com`. |
| `--no-ssl-verify`                         | Disables SSL verification when the GL2GH extension talks to your GitLab instance. Use this only if your GitLab instance uses a self-signed certificate. All other steps still verify SSL.                                                                                                                     |
| `--archive-url URL`                       | Imports a previously exported archive from a URL, instead of exporting the project from GitLab again.                                                                                                                                                                                                         |
| `--archive-path PATH`                     | Imports a previously exported archive from a local file path, instead of exporting the project from GitLab again.                                                                                                                                                                                             |
| `--keep-archive`                          | Retains the export archive locally instead of deleting it after a successful upload.                                                                                                                                                                                                                          |

## Generating a migration script

If you want to migrate multiple repositories to GitHub Enterprise Cloud at once, use the GitHub CLI to generate a migration script. The resulting script contains one `migrate-repo` command per repository.

To generate a migration script, run the `gh gl2gh generate-script` command.

```shell copy
gh gl2gh generate-script \
  --gitlab-server-url GITLAB_SERVER_URL \
  --github-org DESTINATION \
  --output FILENAME \
  --use-github-storage
```

Replace the placeholders in the command above with the following values.

| Placeholder         | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| GITLAB\_SERVER\_URL | The full URL of your GitLab instance, such as `https://gitlab.com` or `https://gitlab.example.com`.                                                                                                                                                                                                                                                                                                                                                                              |
| DESTINATION         | The destination organization on GitHub.                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| FILENAME            | Um nome de arquivo para o script de migração resultante<br><br>Se estiver usando o Terminal, use uma extensão de arquivo `.ps1`, pois o script gerado exige a execução do PowerShell. Você pode instalar o PowerShell para [Mac](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos?view=powershell-7.2) ou [Linux](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux?view=powershell-7.2). |

By default, the script includes every project the token can access. To scope the script, add `--gitlab-group GROUP`, or `--gitlab-group GROUP --gitlab-project PROJECT` for a single project.

If you are not using GitHub-owned blob storage, see [Configure blob storage](/pt/migrations/using-github-enterprise-importer/migrate-from-gitlab/configure-storage).

### Additional arguments

| Argument                                  | Description                                                                                                                                                                                                                                                                                                   |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--target-api-url TARGET-API-URL`         | Se você estiver migrando para o GHE.com, adicione `--target-api-url TARGET-API-URL`, em que TARGET-API-URL é a URL da API base para o subdomínio da sua empresa. Por exemplo: `https://api.octocorp.ghe.com`.                                                                                                 |
| `--target-uploads-url TARGET-UPLOADS-URL` | If you're migrating to GHE.com and using GitHub-owned blob storage, also add `--target-uploads-url TARGET-UPLOADS-URL`, where TARGET-UPLOADS-URL is the base uploads API URL for your enterprise's subdomain. For example: `https://uploads.octocorp.ghe.com`. This defaults to `https://uploads.github.com`. |

### Reviewing the migration script

After you generate the script, review the file and, optionally, edit the script.

* If there are any repositories you don't want to migrate, delete or comment out the corresponding lines.
* If you want any repositories to have a different name in the destination organization, update the value for the corresponding `--github-repo` flag.
* If you want to change the visibility of a new repository, add or update the corresponding `--target-repo-visibility` flag.

### Migrate repositories

If your trial run was successful, and you were able to complete the follow-up tasks, you can proceed to the real migration.

> \[!WARNING] We recommend halting work in the repositories you are migrating. Any changes made during or after the migration will need to be manually migrated.

Run the script you generated. Replace FILENAME in the commands below with the filename you provided when generating the script.

* If you're using Terminal, use `./`.

  ```shell copy
  ./FILENAME
  ```

* If you're using PowerShell, use `.\`.

  ```shell copy
  .\FILENAME
  ```