Use this file as the only checklist for what to configure on github.com for this repository (Settings UI, branch protection / rulesets, and merge options). Other docs link here instead of repeating steps.
GitHub does not read this file automatically—apply everything below in the web UI (or your org’s infrastructure-as-code).
Settings → Rules → Rulesets (recommended), or Settings → Branches → Branch protection rules (classic).
Create a rule targeting your default branch (usually main).
Enable Require a pull request before merging so:
- Direct pushes to
mainare blocked - Every change is proposed as a PR
Under the same rule:
- Require at least one approving review before merge
- Optionally dismiss stale reviews when new commits are pushed
Solo maintainers: In the usual GitHub flow you cannot approve your own pull request. Leaving required approvals enabled can block merges on a one-person repo. Omit this requirement and rely on required status checks (section 4), PR policy when you use PRs, and local habits such as
just review. See section 12.
When GitHub Actions run on pull requests:
- Open any PR (or create a test PR) and open the Checks tab.
- Note the exact check names (for example
Workflow name / job name). - In branch protection / rulesets, add those checks as required so failing CI blocks merge.
Typical workflow display names include CI or CI Tests, Lint, Security (if present), and PR policy—they differ per repository. Always confirm the exact strings in a pull request’s Checks tab before adding them as required.
Add PR policy / pr-policy (workflow PR policy, job pr-policy) if you want PR
title, body (against .github/PULL_REQUEST_TEMPLATE.md), and commit-subject rules enforced on
GitHub. The PR template file alone does not block merges; this workflow does.
Tip: You can also require Dependency review, labeler, or other workflows; names must match what GitHub shows on the PR.
When you squash merge, GitHub often uses the PR title as the default squash commit subject.
- Use Conventional Commits for PR titles (for example
feat: add export) so the resulting commit onmainstays consistent with local commit-msg hooks and project policy. - Locally,
just precommit-installregisters commit-msg hooks and Git’s commit template (.gitmessage); align PR titles with the same convention when you expect squash merges.
Enable:
- Block force pushes
- Block branch deletion
Optionally restrict who may push (if your org allows bypass lists).
Settings → General → Pull Requests:
- Enable Allow squash merging
- Disable Allow merge commits (unless your policy explicitly needs them)
- Disable Allow rebase merging (optional; squash-only keeps history uniform)
Each merged PR becomes a single commit on main.
Turn on enforcement so admins are subject to the same rules (no silent bypass of protection).
If available for your account, require linear history pairs well with squash merges and avoids merge commits on the default branch.
- Branch protection applies once the protected branch exists; the first push that creates
mainmay succeed before rules are saved. - Prefer: add an initial commit (e.g. README), then apply protection and merge settings, then collaborate via PRs.
Workflows that need API tokens or credentials use Settings → Secrets and variables → Actions
(organization secrets if applicable). Exact names and setup steps depend on the workflow—for
example Codecov is documented next to the docs CI in this template’s docs/ci.md (when
MkDocs is enabled). Never commit secrets or paste them into Copier answers.
Personal and private repositories can still use rulesets, required status checks, and the
workflows in .github/workflows/—the main mismatch with this checklist is required approvals
(section 3) when you are the only human.
Many items above are team gates: they make sense when someone else merges or reviews. Alone, you still can turn them on, but the payoff is uneven:
| Kind | Examples | Solo takeaway |
|---|---|---|
| High value | CI on push / PR, block force push and branch deletion, local pre-commit / just check |
Catches breakage and accidents without a second person. This is where most real enforcement lives. |
| Useful if you like the workflow | Require PR, required status checks on PRs, PR policy as a required check | Mostly self-discipline: you are still approving your own work. Benefits: run CI before merging to main, avoid direct pushes by mistake, keep PR titles/bodies consistent—not independent review. |
| Little extra value | Required approvals, include administrators when you are the only admin | No second human to block bad merges; “no bypass” matters when others share the repo. Safe to skip or treat as documentation for a future team. |
If GitHub settings feel like pointless clicks, lean on CI + local hooks and merge however you prefer (PR or direct), as long as you accept the trade-offs.
Configure a ruleset on main roughly as follows:
- Require a pull request before merging if you want the server to block direct pushes.
- Require status checks to pass—copy exact names from a real PR’s Checks tab (section 4).
- Add
PR policy / pr-policyas a required check if you want PR title, body, and commit subjects enforced before merge. - Do not require approving reviews if you cannot supply a second approver.
- Keep block force pushes, block branch deletion, and include administrators (sections 6 and 8).
These work entirely on your machine:
no-commit-to-branchin.pre-commit-config.yamlblocks commits onmain/masterso you develop on a feature branch (pair with GitHub’s “require PR” if you want the same rule remotely).commit-msghooks (Conventional Commits) run on every commit afterjust precommit-install.pre-pushrunsjust check(read-only full gate: sync, lint, types, tests, pre-commit, audit) beforegit pushsucceeds—slower than commit time, but catches CI failures early. To bypass occasionally (not for routine use):SKIP=just-check git pushorgit push --no-verify.
| Goal | Where to configure |
|---|---|
No direct pushes to main |
Branch protection / rulesets |
| PRs required | Branch protection / rulesets |
| Reviews + required CI | Branch protection / rulesets (skip required reviews if solo — section 12) |
| PR title / body / commits policy | Required check PR policy / pr-policy |
| One commit per PR | Settings → General → Pull requests: squash on, merge commits off |
| Admins follow rules | “Include administrators” / equivalent |
| PR title matches squash commit subject | Use Conventional Commits on PR titles (section 5) |
| Solo: parity without required approvals | Section 12 (rulesets + local hooks) |
| API tokens for workflows | Settings → Secrets and variables → Actions (section 11) |
Required check names depend on which Actions workflows exist in your repository. Always copy the exact strings from a real pull request’s Checks tab before adding them to branch protection.