Branch Protection and Rulesets: Enforce Review
Protect the integration branch
Branch protection and rulesets are hosted repository policies, not local Git settings. They can require reviews or checks and restrict updates such as force pushes. A local branch named main is not protected merely because of its name. Configure the actual service and check effective policy.
Evaluate the proposed change
Our sample policy requires a pull request, one valid independent approval for the current proposal, a successful test from the expected check source on the candidate revision, and no unresolved conversations. All conditions are required by this teaching policy; actual rules can differ, including allowed check conclusions and stale-review settings.
{ "pull_request": true, "approvals": 1, "revision": "B", "checked_revision": "B", "check": "success", "source": "trusted-ci", "unresolved": false}Rulesets and exceptions
Rulesets can target branches or tags and multiple active rulesets can apply together with branch protection. Inspect the target, enforcement status and bypass list; do not infer that a rule is active from its name. Administrative or explicit bypass permissions may affect enforcement. Feature availability varies by plan and repository visibility.
Diagnose a blocked merge
A green test from revision A is not evidence about revision B. A new commit may invalidate prior reviews depending on the configuration. Verify the required check name and source, revision, review status and effective policy. Do not rename a check or disable protection just to obtain a green result.
Practice
Use the policy fixture: start with the eligible candidate, change the checked revision to A, remove the approval, or change the check source. Predict denial in each case. Explain why a simulated pass is not a promise that GitHub will permit merging. In an authorized training repository, verify effective rules and bypass rights separately; no hosted configuration is performed here.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Branch Protection and Rulesets: Enforce Review — knowledge check
Reason about repository trust, security controls and incident response.
What does naming a local branch main establish?
A check passed on A but B is proposed. What should you verify?
What if an active ruleset has an authorized bypass?
All mock gates pass. What is established?
A check name is ambiguous. What is the best next step?