Help Center> CodeArts Repo> User Guide> Cloning or Downloading Code from CodeArts Repo to a Local PC> Using SSH to Clone Code from CodeArts Repo to a Local PC
Updated on 2023-12-06 GMT+08:00

Using SSH to Clone Code from CodeArts Repo to a Local PC

Prerequisites

Your network can access CodeArts Repo. For details, see Network Connectivity Verification.

Cloning Code on the Git Bash Client Using SSH

This section describes how to use the Git Bash client to clone a repository of CodeArts Repo to a local PC.

  1. Download and install the Git Bash client.
  2. Configure an SSH key.
  3. Obtain the repository address. (If there is no repository, create one.)

    On the repository details page, click Clone/Download to obtain the SSH address. You can use this address to connect to CodeArts Repo from the local PC.

    If no SSH key is available, click SSH Keys to configure one. For details, see SSH key.

    You can obtain the SSH address from URL in the repository list of CodeArts Repo.

  4. Open the Git Bash client.

    Create a folder on the local PC to store the code repository. Right-click the blank area in the folder and open the Git Bash client.

    The repository is automatically initialized during clone. You do not need to run the init command.

  5. Run the following command to clone code from CodeArts Repo:

    git clone <repository_address>

    repository_address in the command is the SSH address obtained in 3.

    If you clone the repository for the first time, the system asks you whether to trust the remote repository. Enter yes.

    After the command is executed, a folder with the same name as CodeArts Repo is displayed, and a hidden .git folder exists in the folder, indicating that the repository is cloned.

  6. Run the following command to go to the repository directory:

    cd <repository_name>

    You will be taken to the master branch by default.

If the git clone command fails to be executed, locate the fault as follows:

  • Check whether your network can access CodeArts Repo.

    Run the following command on the Git client to test the network connectivity:

    ssh -vT git@**********.com

    If the returned information contains Could not resolve hostname code**********.com: Name or service not known as shown in the following figure, your network is restricted and you cannot access CodeArts Repo. In this case, contact your local network administrator.

  • Check the SSH key. If necessary, regenerate a key and configure it on the CodeArts Repo console.
  • Only PCs that enabled the IP address whitelist can be cloned on the Git client.

Cloning Code on the TortoiseGit Client Using SSH

This section describes how to use the TortoiseGit client to clone a repository of CodeArts Repo to a local PC.

  1. Download and install the TortoiseGit client.
  2. Obtain the repository address. (If there is no repository, create one.)

    On the repository details page, click Clone/Download to obtain the SSH address. You can use this address to connect to CodeArts Repo from the local PC.

    You can obtain the SSH address from URL in the repository list of CodeArts Repo.

  3. Go to the local directory where you want to clone the repository, and choose Git Clone... from the right-click menu.

  4. In the dialog box displayed, paste the copied repository address to the URL field, select Load Putty Key, choose the private key file, and click OK.

  5. Click OK to start cloning the repository. If you clone the repository for the first time, the TortoiseGit client asks you whether to trust the remote repository. Click Yes.
  6. The cloning duration is affected by the repository size. The following figure shows the cloning process.

Cloning a Repository on Linux or macOS Using SSH

After the environment is configured (see Installing Git for Linux or Installing Git for macOS), the clone operations of the Git client on Linux or macOS are the same as those in Cloning Code on the Git Bash Client Using SSH.