Batch migrate Git data from third-party code repositories such as GitHub, Gitee, or Coding to Codeup by using the Codeup-CLI tool, reducing migration costs and minimizing business impact.
Prerequisites
Make sure the Codeup-CLI tool is installed and running correctly. For more information, see Install Migration Tool.
Preparation
Codeup-CLI batch migrates Git data, including source code, branches, commits, and tags, from third-party code repositories.
-
Before you migrate a production repository, run a test migration on a non-production repository to ensure that your configuration is correct.
-
During the migration, restrict write access to the source third-party code repository. Once a repository is successfully migrated, rerunning the migration does not sync new commits from the source repository.
Step 1. Define the configuration file
The configuration file specifies the migration source, target, and scope. You only need to provide credentials for either HTTP or SSH clone, not both.
|
Source parameters |
Required |
Description |
|
platform |
Required |
Set the value to |
|
username |
Required if using HTTP clone |
The username for HTTP clone on the third-party platform. |
|
password |
Required if using HTTP clone |
The password for HTTP clone on the third-party platform. *Note: GitHub requires a personal access token. Password-based authentication is no longer supported. |
|
localSSHKeyPath |
Required if using SSH clone |
The full path to the local private key that matches the SSH key configured on the third-party platform. Example: |
|
Target parameters |
Required |
Description |
|
host |
Required |
The domain name of Alibaba Cloud DevOps. Example: |
|
accessKey |
Required |
A valid personal access token with read and write permissions for the code repository and code group. For more information, see Obtain a personal access token. |
|
username |
Required for HTTP clone |
The username for HTTP clone in Codeup. For the central site, set the username in . For regional sites, view the username in . |
|
password |
Required for HTTP clone |
The password for HTTP clone in Codeup. For the central site, set the password in . For regional sites, set it in . If you cannot set a password, you can use a personal access token instead. |
|
localSSHKeyPath |
Required for SSH clone |
The full path to the local private key that matches the SSH key configured in Codeup. Example: |
The following example shows a simplified config.yaml file that uses SSH authentication:
# Required. The version of the configuration file. Set to "v2".
version: "v2"
import:
source:
platform: "common"
localSSHKeyPath: "/Users/****/.ssh/id_rsa"
target:
# The domain name of Alibaba Cloud DevOps.
host: "https://***.devops.alibabacloudcs.com"
# Your personal access token. This token must have read and write permissions for the code repository and code group.
accessKey: "pt-******03GFpdmIedUgug****_******-3734-484a-9b4b-248569f78c9d"
localSSHKeyPath: "/Users/****/.ssh/id_rsa"
# The path to the migration scope file defined in Step 2.
projectListPath: "/Users/****/workspace/projects.csv"
# The working directory for the migration. The directory is automatically cleared after the migration is complete.
workDir: "/Users/****/workspace"
Step 2. Define the migration scope
Create a file that lists the code repositories to migrate.
Run the following command to generate a template file for the migration scope. The file path must match the projectListPath value in Step 1.
./codeup-cli import --gen project
The command generates a projects.csv file in the current directory. Each line specifies a repository to migrate in the format: [Full URL of source repository],[Relative path of target repository in Codeup],[Repository visibility]. The following example shows the file format:
# ,,
https://github.com/namesapce/demo.git,namesapce/demo,10
# ,,
https://gitee.com/namesapce/demo.git,namesapce/demo,10
# ,,
https://e.coding.net/namesapce/demo.git,namesapce/demo,10
For repository visibility, 0 indicates private, and 10 indicates organization-wide public. All other values default to 10 (organization-wide public).
Before you run the migration, delete the example entries and replace them with your actual repository information.
Step 3. Run the migration
After the configuration file and migration scope file are ready in your working directory, run the following command to start the migration:
./codeup-cli import --run true --config=./config.yaml
# The output displays the migration progress and any errors.
-
If the migration fails for a repository, the tool marks it as failed.
-
If you run the import command again, the tool skips successfully migrated repositories and retries only the failed ones.
-
Migrations from GitHub may time out due to network issues. If a timeout error occurs, check your network connectivity and try again.
After the tool finishes, check the migrated repositories in your Codeup organization to verify the results.
For issues you cannot resolve, join the DingTalk support group (ID: 32027065).