Updated on 2023-07-25 GMT+08:00

Forking a Repository

Application Scenarios

You can fork a CodeArts Repo repository based on an image repository, make changes to the fork, and merge the changes to the source repository. Before changes are merged, the changes of the fork or the source repository will not affect each other.

As shown in the following figure, fork is applicable to the development scenario where a large-scale project contains multiple sub-projects. The complex development process occurs only in image repositories and the project repository (source repository) is not affected. Only new features that are completed can be merged to the project repository. Fork can be considered as a team collaboration mode.

Differences Between Forking a Repository and Importing an External Repository

The two modes are both repository replication. The main difference lies in the association between the source repository and the copied repository. The details are as follows:

  • Fork
    • Forks are used to copy repositories on CodeArts Repo.
    • A fork generates a repository copy based on the current version of the source repository. You can apply for merging changes made on the fork to the source repository (cross-repository branch merge), but you cannot pull updates from the resource repository to the fork.
  • Import
    • You can import repositories of other version management platforms (mainly Git- and SVN-based hosting platforms) or your own repository to CodeArts Repo.
    • An import also generates a repository copy based on the current version of the source repository. The difference is that you can pull the default branch of the source repository to the repository copy at any time to obtain the latest version, but you cannot apply for merging changes made on the repository copy to the source repository.

Forking a Repository

  1. Access the repository list page.
  2. Click a repository name to go to the target repository.
  3. Click Fork in the upper right corner of the page. In the Fork Repository dialog box that is displayed, select the target project, enter the repository name, and select Allow project members to access the repository.

  4. Click OK to fork the repository.

Viewing the List of Forked Repositories

  1. Access the repository list page.
  2. Click the source repository name.
  3. Click Fork in the upper right corner of the page to view the list of forked repositories, as shown in the following figure.

    You can click the name of a forked repository to access the repository.

Merging Changes of a Fork to the Source Repository

  1. Access the repository list page.
  2. Click the name of the forked repository.
  3. Click the Merge Requests tab.

  4. Click New. The Create Merge Request page is displayed.

    Source Branch is the one that requests merging.

    Target Branch is the one that merges content.

  5. Click Next. The page for creating a merge request is displayed. The subsequent operation process is the same as that of creating a merge request in the repository. For details, see Creating a Merge Request.

A cross-repository MR belongs to the source repository and can be viewed only on the Merge Requests tab of the source repository. Therefore, reviewers, approvers, and mergers must be members of the source repository.