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

Forking a Repository

Application Scenarios

You can fork a CodeHub 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. Therefore, forks can be considered as a team collaboration mode.

Forking a Repository

  1. Access the repository list page.
  2. Find the target repository in the repository list, click the repository name to access the repository, and click Fork.
  3. In the Fork Repository dialog box, select the project to which the fork belongs, and enter the fork name.

    If Allow project members to access the repository is selected, the project manager and developers of the project are added to the repository as the administrator and common members of the repository, respectively.

  4. Click OK to fork the repository. The repository list page is displayed.

Merging Changes of a Fork to the Source Repository

  1. Access the repository list page.
  2. Click a forked repository.
  3. On the Files tab page of the repository, click next to the branch, select Create File from the expanded items, edit the file name and content, and click Save.
  4. Switch to the Merge Requests tab page.
  5. Click Create Merge Request. The Create Merge Request page is displayed.

  6. Source Branch is the one that requests merging.

    Target Branch is the one that merges content.

  7. Click Next. The page for creating a merge request is displayed. The subsequent operation process is the same as that of branch merge review in the repository.

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