跳到主要内容

Repository Mirroring

Repository mirroring management functions are used to configure and manage repository mirrors, configuring repository mirrors can achieve automatic synchronization of branches, tags, and commit information between different platforms.

GitCode supports two types of mirrors: Pull and Push.

  • Push: Used to automatically mirror the GitCode repository to GitHub or Gitee.
  • Pull: Used to mirror the GitHub or Gitee repository to GitCode.

Access Settings


First, enter the project homepage, click on "Project Settings" in the tab bar, then click on "Repository Mirroring" in the sidebar.

image-20241227175028255

Adding a Push Mirror


The Push mirror is used to automatically mirror the GitCode repository to GitHub or Gitee.

提示
  • The timeout for pushing code files is 30 minutes, and the timeout for pushing LFS files is 150 minutes.
  • Each repository commit will automatically trigger a synchronization operation, which will directly overwrite the mirrored repository code.
  • Up to five mirrored repositories can be pushed simultaneously.
  1. Select "Push" in the tab bar, then click "Add Mirror".

    image-20241227175309393

  2. Enter the target project's address, the account and personal token of the target platform, then click confirm to complete the addition.

    image-20241227175552346

  3. After adding, as shown below, updates from the GitCode repository will be automatically pushed to the target repository.

    image-20241227184406892

Setting a Pull Mirror


The Pull mirror will be used to mirror the GitHub or Gitee repository to GitCode.

You can configure the Pull direction mirror in the following way:

  1. Select "Pull" in the tab bar, fill in the required specific information.

    提示

    Overwrite Fork Branches (pull-f) is an option that controls how the mirror pull operation handles differences between local and remote branches.

    When enabled: The mirror pull operation will force update all branches (including forked branches) regardless of whether there are local changes or conflicts. This is useful when you need to force synchronize all branches to the remote version but may result in data loss locally.

    When disabled: Provides stricter protection for local branches, avoiding overwriting local data due to remote changes; suitable for scenarios where local modifications need to be preserved and data security must be ensured.

    image-20241227185319599

  2. After clicking "Set Mirror", the operation is completed, and the result is shown below.

    image-20241227185451937

Bi-directional Mirroring


Bi-directional mirroring refers to configuring both types of mirroring synchronization methods for the same GitHub (or Gitee) repository on GitCode. After configuration, any changes made in either GitHub or GitCode will be automatically synchronized to the other platform.

注意

To avoid issues with code loss, it is recommended to follow these rules when using bi-directional mirroring:

  1. Avoid simultaneous commits: Do not submit code to both the GitCode and GitHub repositories at the same time to avoid data loss due to conflicts or overwrites.
  2. Maintain a time interval: Ensure that the time interval between submitting code to the GitCode and GitHub repositories is greater than 30 minutes to ensure that the synchronization process is completed and the status is consistent.

By following these rules, you can enjoy the convenience brought by bi-directional mirroring while minimizing potential risks.