Protected Branches
Protected branches are used to ensure the security, stability, and consistency of the code. They allow project administrators and teams to restrict access and changes to specific branches, preventing unnecessary error merges and maintaining the stability of the codebase.
Key Features
Protected branches apply a series of protective measures to the specific branch to ensure the safety 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 designated individuals or team members can merge changes.
- Disallow Direct Pushes: Prevent direct submissions to the protected branch, typically requiring changes to be submitted via Pull Requests.
- Require Pipeline Checks: Ensure that submitted changes pass the checks in the continuous integration/continuous delivery (CI/CD) pipeline.
Enabling Protected Branches
-
Navigate to the branch list page.
-
Click on the protected branch icon on the right side of each branch to set up protected branch settings.
-
Grant different roles different permissions, setting up a whitelist for push and merge operations.
Protected branches provide a safeguard mechanism to ensure the safety and stability of key branches. This is particularly important for maintaining large projects and multi-team collaborations, as it reduces the risk of code conflicts and unexpected errors, thereby ensuring smoother project progress.