GitHub Branch Rulesets can protect main from force push and deletion without requiring PRs
GitHub started showing a "Your main branch isn't protected" warning in repository settings. The old Branch Protection Rules still work, but Rulesets are now the recommended approach.
For personal repos where code changes go through PRs but content/ gets pushed directly to main, requiring PRs would block the content workflow. Rulesets let you pick only the rules you need.
Go to Settings → Rules → Rulesets → New branch ruleset and configure:
Ruleset name: Protect main
Enforcement status: Active
Target branches: Include default branch
Block force pushes: ON
Restrict deletions: ONLeave everything else (Require PR, Require status checks, etc.) OFF. This prevents accidents like git push --force or git branch -d main while allowing normal pushes.
Unlike the older Branch Protection Rules, Rulesets can combine multiple rules and apply across an entire Organization. For personal repos, starting with just force push protection + deletion protection is the easiest first step.
