Skip to content

Instantly share code, notes, and snippets.

@nbassler
Created June 28, 2026 11:45
Show Gist options
  • Select an option

  • Save nbassler/06dd53767812884cdb92690704dad8c7 to your computer and use it in GitHub Desktop.

Select an option

Save nbassler/06dd53767812884cdb92690704dad8c7 to your computer and use it in GitHub Desktop.
Protecting the `main` branch with a GitHub Ruleset
1. **Ruleset name**: `protect-main`
2. **Enforcement status**: Active
3. **Target branches**: Add target → `main`
**Rules to enable:**
- ✅ **Restrict deletions** — prevents anyone deleting the branch
- ✅ **Require a pull request before merging** — no direct pushes to main
- Required approvals: `1` (or `0` if solo, just to enforce the PR flow)
- ✅ **Require status checks to pass** — add `test` (from `ci.yml`) and `ruff` (from `lint.yml`)
- ✅ Require branches to be up to date before merging
- ✅ **Block force pushes**
> **Note:** If you are the sole contributor, set required approvals to `0` — the main value is that CI must be green before anything lands on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment