main, release/*, and others from accidental or unauthorized changes.
Overview
Branch protection allows you to:- Block direct pushes (require pull requests)
- Prevent force pushes
- Block branch deletion
- Require code reviews
- Enforce status checks
- Restrict who can push
Quick Start
Commands
List Rules
Add a Rule
Update a Rule
Remove a Rule
Show Rule Details
Check Operations
Verify if an operation would be allowed:Protection Status
See a summary of protection for a branch:Options
Push Restrictions
Review Requirements
Status Checks
Metadata
Presets
wit includes built-in presets for common protection scenarios:Basic
- Blocks force push
- Blocks deletion
- Allows direct push
Standard
- Requires pull request
- Requires 1 approval
- Dismisses stale reviews
- Blocks force push
- Blocks deletion
Strict
- Requires pull request
- Requires 2 approvals
- Dismisses stale reviews
- Requires code owner review
- Requires status checks
- Requires branch up-to-date
- Blocks force push
- Blocks deletion
Pattern Matching
Protection rules support glob-style patterns:
Examples:
Storage
Branch protection rules are stored in.wit/branch-protection.json: