How to add GitHub branch protection rules
This guide provides step-by-step instructions on how to add branch protection rules to a repository. By following these steps, users can ensure that certain conditions, such as requiring pull request reviews and passing status checks, are met before merging changes to the specified branch. This guide is essential for anyone who wants to enforce stricter controls and increase the quality of code changes in their repository.
Aaron Podolny
|
9 steps
|
2 minutes
GitHub
1
Navigate to the repo you'd like to protect.
2
Click "Settings"
3
Click "Branches"
alert ordinal icon
Heads Up! There can only be one rule per branch, but each rule can have multiple conditions. If there is already a rule for a branch, just edit it.
4
Click "Add rule"
5
Click the "Branch name pattern" field.
6
Type "master"
7
Click the "Require pull request reviews before merging" field.
8
Click the "Require status checks to pass before merging" field.
9
Click "Create"