Created
June 28, 2026 11:45
-
-
Save nbassler/06dd53767812884cdb92690704dad8c7 to your computer and use it in GitHub Desktop.
Protecting the `main` branch with a GitHub Ruleset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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