branches section configures branch protection rules for repositories. Branch protection enforces certain workflows, such as requiring pull request reviews or status checks before merging.
Basic Configuration
The name of the branch to protect. Use
default to protect the repository’s default branch (dynamically resolved).Protection Settings
Branch protection configuration. Set to
null or {} to remove branch protection.Pull Request Reviews
Require at least one approving review on a pull request before merging. Set to
null to disable.The number of approvals required (1-6).
Dismiss approved reviews automatically when a new commit is pushed.
Blocks merge until code owners have reviewed.
Whether the most recent reviewable push must be approved by someone other than the person who pushed it.
Status Checks
Require status checks to pass before merging. Set to Using
When you include
null to disable.Require branches to be up to date before merging.
The list of status checks to require in order to merge into this branch. Use
{{EXTERNALLY_DEFINED}} as a special value to allow status checks to be managed outside of Safe Settings (prevents Safe Settings from overwriting manually added checks).Using {{EXTERNALLY_DEFINED}}
When you include {{EXTERNALLY_DEFINED}} in the contexts array, Safe Settings will not manage the status checks list. This allows you to add status checks manually through the GitHub UI or other tools.Administrator Enforcement
Enforce all configured restrictions for administrators. Set to
true to enforce required status checks for repository administrators. Set to null to disable.Push Restrictions
Additional Protection Rules
Require all conversations on code to be resolved before a pull request can be merged.
Require linear history (prevent merge commits).
Require signed commits.
Allow users with push access to delete matching branches.