Branch Protection
Branch protection is a tool for encouraging the desired behavior from contributors. This is accomplished by setting up a rule requiring a pull request before merging. The default setting will allow admins to override this requirement, which is useful if you need to perform an emergency merge to fix a problem.
To set up branch protection, go to Settings > Branches and create a branch protection rule for your default branch (usually “main” or “master”). For example, a common pattern is to set up a branch protection rule for main that:
- Requires a pull request before merging
- Requires at least one approval
- Requires an approved review by Code Owners