Skip to content
BENIBIX Learn

Branch Protection

Development🔀 Version ControlCollaboration

Also known as Protected Branch, Branch Protection Rule, Branch Ruleset

Rules that keep changes off a branch until reviews and tests pass.

Think of it like

Think of it like a lock on the front door. Only guests who pass the checks get in.

Example

Emma locks main on GitHub. Now each pull request needs one approval and passing tests before it can merge.

Why it matters

It turns good habits into rules the code host enforces.

Definition

Branch protection is a set of rules a code host puts on a branch, usually main. It can require a pull request before anything is merged. It can require an approving review and passing tests. On GitHub, it blocks force pushes and deleting the branch by default. Nobody can then push broken code to main by mistake.
The lock on main: a review and passing tests come first.

Common mistake

Letting admins skip the rules. Then the one rushed fix that breaks main gets through.

Key takeaways

  1. 1
    Gate the branch. Changes come only through checks.
  2. 2
    Reviews and tests. Both must pass before merge.
  3. 3
    No force push. History on main cannot be rewritten.

Compare

Learn it properly