Branch Protection
This document describes recommended GitHub branch protection settings for the default branch.
Recommended Settings
- Require a pull request before merging
- Require at least one approval
- Require status checks to pass before merging
- Dismiss stale approvals when new commits are pushed
- Prevent force pushes
- Prevent branch deletion
- Optionally require review from code owners
How To Enable (GitHub UI)
- Open the repository on GitHub.
- Go to Settings.
- Select Branches in the left sidebar.
- Under Branch protection rules, click Add rule.
- Enter the default branch name, for example
master. - Enable the settings listed in the Recommended Settings section.
- Click Create or Save changes.