Lesson 14 / 20
Protecting the Main Branch
Protect main with branch protection rules that require reviews and passing checks before merging.
Why protect main
Branch protection rules (or newer rulesets) stop force-pushes and direct commits to main, requiring changes to go through a reviewed pull request.
Required reviews & status checks
You can require at least one approval and passing CI checks before a PR is even allowed to merge.
Where to configure
Settings → Branches → Add rule — pick the branch pattern (e.g. main) and the requirements to enforce.