Help Center> CodeArts Repo> User Guide> New Version (Recommended)> Associating the CodeArts Repo Repository
Updated on 2023-07-25 GMT+08:00

Associating the CodeArts Repo Repository

Before using CodeArts Repo, initialize the local project files to a Git repository and associate it with a CodeArts Repo repository.

Prerequisites

You have installed the Git client and bound the SSH key of the Git client to CodeArts Repo.

Procedure

  1. Create a CodeArts Repo repository.

    If you select gitignore based on your local code library, some non-development files will be ignored and will not be managed in Git.

  2. Initialize the local repository to a Git repository.

    Open the Git Bash client in your repository and run the following command:

    git init

    The following figure shows that the initialization is successful. The current folder is the local Git repository.

  3. Bind the CodeArts Repo repository.

    1. Go to the CodeArts Repo repository and obtain the repository address.
    2. Run the remote command to bind the local repository to the cloud repository.
      git remote add <repository_alias> <repository_address>

      Example:

      git remote add origin git@*****/java-remote.git  # Change the address to that of your repository.

      By default, origin is used as the repository alias when you clone a remote repository to the local computer. You can change the alias.

      If the system displays a message indicating that the repository alias already exists, use another one.

      If no command output is displayed, the binding is successful.

  4. Pull the master branch of the CodeArts Repo repository to the local repository.

    This step is performed to avoid conflicts.

    git fetch origin master  # Change origin to your repository alias.

  5. Commit local code files to the master branch.

    Run the following commands:

    git add .
    git commit -m "<your_commit_message>"

    The following figure shows a successful execution.

  6. Bind the local master branch to the master branch of CodeArts Repo repository.

    git branch --set-upstream-to=origin/master master  # Change origin to your repository alias.

    If the following information is displayed, the binding is successful.

  7. Merge the files in the CodeArts Repo repository and local repository and store them locally.

    git pull --rebase origin master   # Change origin to your repository alias.

    The following figure is displayed, indicating that the merged repository has been placed in the working directory and repository.

  8. Push the local repository to overwrite the CodeArts Repo repository.

    Run the push command because the repositories have been bound:

    git push

    After the operation is successful, pull the repository to verify that the version of the CodeArts Repo repository is the same as that of the local repository.