How to configure branch protection
  • 2 Minutes to read
  • Dark
    Light
  • PDF

How to configure branch protection

  • Dark
    Light
  • PDF

Article summary

There are many reasons to use branch protection, and many individual permissions that can help your team model your workflow.

Here is an interactive demo that walks you through creating basic branch protections

Step-by-step

Here are step-by-step instructions that match the interactive demo above.

  1. Click Repository->🔧Settings
  2. Click on Branches on the Settings->Left-hand side-menu
  3. Click "Add New Rule"
  4. Type "main" into the "Protected Branch Name Pattern" field.
  5. Scroll to the bottom.
  6. Click "Save Rule"

Branch protection settings

There are powerful and highly customizable branch protection settings. If you're not sure which settings are best to match your process, don't hesistate to reach out to support@allspice.io

Disable push

This is recommended for your main branch and any closed or finalized branches. This keeps commits from being able to be pushed to this branch.

Enable push

Anyone with write access can push a commit to this branch.

Whitelist restricted push

Only people on the whitelist can push commits to this branch. This is to allow admin / expert fixing or adjusting of a repo, without giving everyone access.

Enable merge whitelist

Repo admins can have their merge permissions removed by enabling the merge whitelist and omitting them from the whitelist. Only people on the whitelist will be able to merge the design review.

Enable status check

Requires status checks to pass before merging.

Required approvals

Set to zero if allowing merge without approvals. Set to a number to count the number of required approvals to allow a merge. Note: if you change this after approvals come in, the design review won't count the number of approvals correctly.

Restrict approvals to whitelisted users or teams

We highly recommend using this feature, as our teams functionality is quite robust. Restrict approvals to people or teams added to this list.

Block merge on rejected reviews

Enable to block merging, even if there are enough approvals, if there is a rejected review. Repo admins will be able to merge unless you use a merge whitelist.

Block merge on official review requests

Enable to block merging, even if there are enough approvals, if there is an official review request. Repo admins will be able to merge unless you use a merge whitelist.

Dismiss Stale approvals

When new commits change the content of the pull request are pushed to the merge-in branch, old approvals will be dismissed.

Require signed commits

Enable this to reject commits that are not signed or the signature is unverifiable.

Block merge if design review / pull request is outdates

Enable this to block merging if the head branch is behind the base branch

Protected file patterns

Files that match these patterns will not be allowed to change, even if the user has permissions.

Unprotected file patterns

Files that match these patterns will be allowed to change directly if the user has write permissions

Update settings

You must click this to save any changes. Note that changing a design review after approvals have been made may cause the approvals to be miscounted, and you will have to manual merge.


Was this article helpful?