Help Center/ CodeArts Repo/ User Guide/ Old Version/ Repository Migration/ Importing a Remote Git Repository to CodeHub
Updated on 2023-07-25 GMT+08:00

Importing a Remote Git Repository to CodeHub

Background

CodeHub allows you to import Git-based remote repositories.

Git-based remote repositories are cloud repositories hosted in storage services such as GitHub.

Cloning the Git Repository to the Local host and Associating and Pushing It to CodeHub

Clone the remote repository to the local host, and then associate and push the repository to the cloud code hosting.

  1. Install and configure the Git client.
  2. Download a bare repository using the source repository address.

    The following uses GitHub as an example:

    1. Open and enter the address of the GitHub code repository in a browser.
    2. Click Code on the right, choose the HTTPS tab, and click the Copy Icon on the right.

    3. Open the Git Bash client on the local host, run the following command to clone the repository to the local computer, and run the cd command to go to the repository directory:
      git clone --bare <source_repository_address>

  3. Associate the local repository with CodeHub and push it to CodeHub.

    1. On the CodeHub homepage, click Create Directly. In the Permissions area, do not select Allow generation of a README file.

    2. Go to the repository details page created in 1, click Clone/Download, and click the Clone with SSH or Clone with HTTPS as required. Then, click to obtain the repository address.

      In this example, the HTTPS address is used.

    3. In the root directory of local source code, open the Git Bash client and run the following command to push the local repository to the new repository:
      git push --mirror <new_codehub_repository_address>

      When the command is executed, the system prompts you to enter the HTTPS account and password of the CodeHub repository. Enter the correct account and password. (For details, see Obtaining an HTTPS Password.)

      If your source repository has branches and tags, they will also be pushed to the CodeHub cloud repository.

After the push is successful, check whether the migration is complete in the code hosting cloud repository. (For details, see Repository List.)