tencent cloud

Feedback

Set Protected Branch

Last updated: 2023-12-25 17:08:18
    This document describes how to set protected branches.

    Open Project

    1. Log in to the CODING Console and click the team domain name to go to CODING.
    2. Click
    
    in the upper-right corner to open the project list page and click a project icon to open the corresponding project.
    3. Select Code Repositories in the menu on the left and click Branches to go to the branch management page.
    Branch protection is a special function CODING uses to limit Git code permissions. Selected branches can be protected from unreported and unauthorized changes.
    When you enable branch protection, protected branches are marked with a green shield in the branch list. To modify a protected branch, members must create a new branch and modify it. Then, they submit a merge request to invite other members to review the code. If the review result is Allow Merge, the merge operation can be performed.
    

    Set Protected Branch Rules

    In a code repository, go to Settings > Branch Settings. There, you can use wildcards to intelligently set protected branches. Branches that match the set name rules are judged to be protected branches.
    
    Disallow Force Push: Enabled by default. Even users with permission to perform git push cannot use git push -f to force modify the branch commit history. We strongly recommend you enable this option when multiple people collaborate on a branch. This ensures that users must use new commits to change the branch history, rather than modifying previous commits.
    Enable Status Check: By setting the specification check conditions or setting a code scanning scheme in the CI, merges are allowed only after the CI is successful. For more information, see Continuous Integration > Trigger Rules.
    Automatically Add Branch Admin as Reviewer: When this option is enabled, the relevant branch admins are automatically set as reviewers for all merge requests involving protected branches. When the number of branch admins exceeds the Number of Reviewers Authorizing Merge, an appropriate number of reviewers are randomly selected from among the branch admins. For example, if there are three branch admins and the number of reviewers is 2, the system randomly selects two of the three admins as reviewers.
    Enable Review by Code Owner: When this option is enabled, for merge requests involving protected branches, any modification must be reviewed by the relevant code owner before the merge is allowed. For more information, see Code Owner.
    Number of Reviewers Authorizing Merge: This is used to set the number of branch admins that must authorize a merge request. If no branch admins are set for a protected branch, a merge request must be authorized by one ordinary member before the merge is allowed.

    Specify Branch Admins

    Branch Admin is optional. After an admin is added, the admin must Allow Merge for every merge request. By default, admins are restricted by the conditions of protected branches, and they need to create merge requests to modify the branches. Select Allow Direct Push to allow admins to directly modify the content of protected branches.
    
    If members do not have permissions for a branch (e.g., when they are not admins of a protected branch), they will receive the following error message when they try to push to this branch.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support