跳到主要内容

Protected Branches

The protected branches feature is used to ensure the security, stability, and consistency of the code. It allows project administrators and teams to limit access to and changes on specific branches, preventing unnecessary merge errors and maintaining the stability of the code repository.

Key Features


Protected branches apply a series of protective measures to ensure the security and consistency of the codebase. These measures include:

  • Mandatory Code Review: Changes must be reviewed and approved via Pull Requests before being merged into the protected branch.
  • Restrict Merge Permissions: Only specific individuals or team members can merge changes.
  • Prohibit Direct Pushes: Prevent direct submissions to the protected branch; changes usually need to be submitted via Pull Requests.
  • Require Pipeline Checks: Ensure that submitted changes pass checks in the continuous integration/continuous delivery (CI/CD) pipeline.

Enabling Protected Branches


  1. Navigate to the branch list page.

  2. Click on the protected branch icon on the right side of each branch to configure the protected branch settings.

  3. Assign different permissions to different roles, set up whitelists for push and merge operations.

    image-20241226153445948

Protected branches provide a mechanism for teams to safeguard key branches, ensuring the security and stability of the code. This is particularly important for maintaining large projects and multi-team collaborations, as it reduces the risk of code conflicts and unintended errors, thereby allowing the project to proceed smoothly.