Updated on 2024-07-05 GMT+08:00

Protected Branches

To configure protected branches, you can choose Settings > Policy Settings > Protected Branches on the repository details page.

The settings take effect only for the repository configured.

All repository members can view this page. For details about whether a repository member has repository setting permissions, refer to the Permissions page.

Functions of Protected Branches

  • Ensure branch security and allow developers to use MRs to merge code.
  • Prevent non-administrators from pushing codes.
  • Prevent all forcibly push to this branch.
  • Prevent anyone from deleting this branch.

When you create a repository, the repository automatically sets the default branch (generally master) as the protection branch to ensure repository security.

After you set a protected branch, the protected branch cannot be used as the target branch for code merging.

Editing Protected Branches

You can set a protected branch. The procedure is as follows:
  • Click Create Protected Branch. In the Added Protected Branch dialog box, select a branch from the drop-down list or manually enter a branch name or wildcard character, select the corresponding permissions or assign permissions to users, and click OK.
  • Click to modify the configuration of the protected branch.
  • Click to delete the protected branch.

  • Configure the whitelist: To assign permissions to one or more members of an unauthorized role, you can select Push and Merge under Members and click the drop-down list to add the members to the whitelist.

  • Only developers, committers, administrators, and project managers have the Push and Merge permissions.
  • If Administrator/Project manager, Committer, and Developer are selected for Push, all these roles have the permissions. In this case, you do not need to select Push or Merge under Members.
  • You can create, edit, and delete protected branches in batches.