Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. For more information, see "GitHub's products."
Repository administrators can enforce required status checks before a branch is merged in a pull request or before commits on a local branch can be pushed to the protected remote branch.
Before enabling required status checks on a branch, you must first:
- Set the branch up as a protected branch.
- Configure the repository to make use of the Status API. For more information, see "Building a CI Server" in the GitHub Developer documentation for an introduction to this API.
You can automatically enforce protected branch settings for some or all branches in your repository. For more information, see "Configuring protected branches."
On GitHub, navigate to the main page of the repository.
Under your repository name, click Settings.
In the left menu, click Branches.
Under Protected Branches, select the branch you want to mark with a required status check using the drop-down menu.
- Select Require status checks to pass before merging.
- Optionally, deselect Require branches to be up to date before merging. If selected, this ensures that the branch is tested with the latest code on the base branch.
- From the list of available status checks, select the ones you want to make required.
Optionally, select Include administrators. This enforces the required status checks on the repository administrators.
Optionally, deselect Require branches to be up-to-date before merging. If selected, this ensures that the branch is tested with the latest code on the base branch.
- Click Save changes.
Tip: To successfully merge a pull request into a base branch that has required status checks enabled, the pull request's head branch must be up-to-date with the base branch.