Branch protection & required reviewers

Protect important branches from direct pushes and require pull request reviews.

Updated Aug 4, 2026Git & Version Control

Branch protection keeps critical branches — like main or production — safe from accidental or unreviewed changes.

Enable branch protection

  1. Open your project’s Settings → Branches page.
  2. Add a rule for a branch (for example, main).
  3. Choose what to enforce.

Options

  • Prevent direct pushes — changes to the branch must come through a pull request.
  • Require reviewers — a pull request needs approvals before it can be merged.
  • Require status checks — builds must pass before merging (available with CI/CD enabled).

How it feels in practice

With protection on, git push origin main is rejected with a helpful message. Instead, you open a pull request, get it reviewed and approved, and merge — keeping your history clean and your main branch shippable.

Branch protection & required reviewers