Skip to main content
Collaborate at HartSign in

← Back to Help Center

Protected branches

Lock the default branch against direct edits and pushes.

  1. 1. Open repository settings

    Navigate to /{owner}/{repo}/settings (maintainer access required). Org admins see additional controls.

  2. 2. Find Branch protection

    The Branch protection section explains that the default branch is protected from direct pushes and browser edits when enabled.

  3. 3. Toggle protection

    Click Enable protection or Disable protection. A success message confirms Branch protection updated.

  4. 4. Require review before merge

    On the Branches tab, maintainers can check Require review to merge next to any branch. When enabled, pull requests targeting that branch cannot be merged until at least one Approve review exists with no outstanding Request changes. This does not affect direct merges from the Branches page.

  5. 5. Work on a feature branch

    With protection on, create a branch under Branches, commit there, compare, then merge into the default branch.