Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
Protecting a branch requires admin or owner permissions to the repository.
Note: Passing new arrays of users and teams replaces their previous values.
Note: The list of users, apps, and teams in total is limited to 100 items.
Note
This section can be applied to repos/<file>.yml or suborgs/<file>.yml. It will most commonly appear in the individual repos though.
# These settings are synced to GitHub by https://github.com/github/safe-settings
branches:
- name: default
protection:
required_pull_request_reviews:
required_approving_review_count: 2
dismiss_stale_reviews: true
require_code_owner_reviews: true
require_last_push_approval: true
required_signatures: true
require_linear_history: false
bypass_pull_request_allowances:
apps:
- Jarvis
- Edith
users:
- TonyStank
teams:
- Avengers
dismissal_restrictions:
users:
- Hulk
teams:
- Revengers
required_status_checks:
strict: true
checks:
- stark-industries/barndoor-protocol
- stark-industries/sokovia-accords
enforce_admins: true
restrictions:
users:
- starlord
teams:
- guardians|
Require status checks to pass before merging. Set to Properties of
|
Example:
branches:
- name: default
protection:
required_status_checks:
strict: true
checks:
- stark-industries/barndoor-protocol
- stark-industries/sokovia-accords
... |
|
Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to |
branches:
- name: default
protection:
required_status_checks:
strict: true
checks:
- stark-industries/barndoor-protocol
- stark-industries/sokovia-accords
enforce_admins: true |
|
Require at least one approving review on a pull request, before merging. Set to Properties of
|
branches:
- name: default
protection:
required_pull_request_reviews:
required_approving_review_count: 2
dismiss_stale_reviews: true
require_code_owner_reviews: true
require_last_push_approval: true
required_signatures: true
bypass_pull_request_allowances:
apps:
- Jarvis
- Edith
users:
- TonyStank
teams:
- Avengers
dismissal_restrictions:
users:
- Hulk
teams:
- Revengers
... |
|
Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories. Set to Properties of
|
Example:
branches:
- name: default
protection:
...
restrictions:
users:
- superman
teams:
- justice-league
... |
|
Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to Default: |
branches:
- name: default
protection:
require_linear_history: false
... |
|
Permits force pushes to the protected branch by anyone with write access to the repository. Set to true to allow force pushes. Set to false or null to block force pushes. Default: false. For more information, see "Enabling force pushes to a protected branch" in the GitHub Help documentation. |
branches:
- name: default
protection:
allow_force_pushes: false
... |
|
Allows deletion of the protected branch by anyone with write access to the repository. Set to Default: |
branches:
- name: default
protection:
allow_deletions: false
... |
|
If set to Default: |
branches:
- name: default
protection:
block_creations: false
... |
|
Requires all conversations on code to be resolved before a pull request can be merged into a branch that matches this rule. Set to Default: |
branches:
- name: default
protection:
required_conversation_resolution: false
... |
|
Whether to set the branch as read-only. If this is Default: |
branches:
- name: default
protection:
lock_branch: false
... |
|
Whether users can pull changes from upstream when the branch is locked. Set to true to allow fork syncing. Set to Default: |
branches:
- name: default
protection:
allow_fork_syncing: false
... |
|
Whether users are required to configure SSH or GPG signatures for all commits pushed to this branch. Default: |
branches:
- name: default
protection:
required_signatures: true
... |