Prerequisites
Before you begin, you need:- An existing project that has an associated Git repository. To associate a repository with a project, see Initialize Repository.
- A target repository that already exists on the target Git provider. does not create the target repository for you. The supported target providers are GitHub, GitLab, and Azure DevOps.
Azure DevOps
If either the source or target repository is hosted on Azure DevOps, you must:- Install the Maia for Azure DevOps application in the Azure tenant that hosts the repository. If the application is already installed in that tenant—for example, because another user has previously connected an Azure DevOps repository to —you can skip this step. Otherwise, follow Installing the Maia app in Azure.
- Add the service principal to the Azure DevOps repository, and grant it explicit Read and Force push (rewrite history, delete branches and tags) permissions.
GitLab
If the target repository is hosted on GitLab, you must:- Provide the personal access token for a GitLab service account using the
Git-Provider-Access-Tokenrequest header. - Add the service account to the group, or to the project that the group belongs to—depending on whether it’s a group-level or project-level service account—with the Maintainer role or higher.
- Allow force pushes on the target repository. Force pushes aren’t allowed by default. You can allow them at the group level, or configure the setting per-repository in the target repository’s protected branch settings.
The
Git-Provider-Access-Token header is optional, and is only required when the target repository is hosted on GitLab. rotates the personal access token immediately after you provide it, and revokes the original. This means a personal access token can only be used once—if you start a migration more than once, for example after a failed attempt, provide a fresh personal access token each time.
Migration modes
Use themode field to choose how the migration runs. The two modes, MIRROR_PUSH and RECONFIGURE, are explained in the table below.
Start a repository migration
Use this endpoint to start an asynchronous migration of the project’s Git repository to the target repository. This request returns amigrationId that you can use to track the progress of this migration.
Request headers
Request fields
Example request
Base URL:POST /v1/projects/{projectId}/repository-migration
Replace {projectId} with your project ID.
Example request header:
providerParameters object with the organization, repository ID, and tenant ID for the target repository:
Git-Provider-Access-Token header in your request, in addition to Authorization:
providerParameters object with the repository ID for the target repository:
Check migration status
Use this endpoint and themigrationId returned by the previous request to poll the status of a migration. Repeat this request until the status field is no longer IN_PROGRESS.
Example request
Base URL:GET /v1/projects/{projectId}/repository-migration/{migrationId}
Replace {projectId} with your project ID and {migrationId} with the migration ID returned when you started the migration.
Example request header:
migrationId: The unique identifier of the repository migration.status: The current status of the migration. The table below explains what each status means.detail: An optional, human-readable description of the migration’s current state, such as a failure reason. This field is only included if this information is available.
Error responses
If an error occurs, the repository migration endpoints return aProblemDetail response body. The table below explains what the included status code means.
