
Any organisation — from a two-person startup to a global charity — benefits from branch protection rules in GitHub. They’re included for free on public repositories (and widely available on paid tiers for private repos). GitLab and Bitbucket offer similar features, but GitHub is the most popular platform, so that’s our focus.
You can configure protections in two ways:
Simple rules per branch — quick to set up, good for small teams.
Reusable policies across multiple repos — ideal for organisations with dozens or hundreds of projects.
What Is a Branch, and Why Protect It?
A branch in Git is just a line of development. Your main or production branch usually represents code that’s ready for deployment. By default, anyone with write access could push directly to it, delete it, or rewrite history — which is risky.
Branch protection puts controls in place to:
The 10 Rules of Branch Protection
Here’s what GitHub offers and what each setting protects you from — with trade-offs explained.
Require Pull Request Before Merging
Require Approvals
Require Status Checks
Require Branch Up-to-Date
main.main changes frequently.Require Conversation Resolution
Require Signed Commits
Require Linear History
Require Deployments Before Merge
Lock Branch
main or release tags.Do Not Allow Bypass
Practical Advice by Team Size
- PR required
- One approval
- CI status checks
- Signed commits
- Conversation resolution
- Restrict direct pushes
- Org-level rulesets
- CODEOWNERS reviews
- Merge queues for velocity
Conclusion
Branch protection is not just about Git hygiene — it’s an AppSec control. It prevents unreviewed, untested, or unauthorised changes from ever reaching production. The inconvenience is minimal compared to the protection it provides.
Every organisation should adopt it — whether via branch-level rules or scalable rulesets.
We help teams of all sizes build secure, practical CI/CD workflows.
Get in touch →