This document outlines the recommended branch protection rules for the main branch in this repository. These settings are designed to provide safety and structure while accommodating a solo developer workflow.
- Navigate to your repository on GitHub
- Click Settings → Branches (in the left sidebar)
- Under "Branch protection rules", click Add rule
- Enter
mainas the branch name pattern - Configure the settings as described below
- Setting: Check "Do not allow force pushes"
- Rationale: Prevents accidental history rewrites that could cause data loss
- Impact: You can still push normally, but cannot use
git push --force
- Setting: Check "Do not allow deletions"
- Rationale: Protects the main branch from accidental deletion
- Impact: The main branch cannot be deleted through the GitHub UI or API
- Setting: Check "Require a pull request before merging"
- Sub-setting: Set "Required approvals" to
0 - Rationale:
- Forces you to work on feature branches
- Provides a review checkpoint even for solo work
- GitHub Copilot can assist with code review
- Creates a clean audit trail of changes
- Impact: You cannot push directly to main; must create PRs from feature branches
- Solo Developer Note: With 0 required approvals, you can merge your own PRs immediately after creation
- Setting: Check "Require status checks to pass before merging"
- Rationale: Ensures automated tests and builds pass before merging
- Impact: PRs cannot be merged if CI/CD checks fail
- Note: Only enable if you have GitHub Actions workflows or other CI/CD configured
- Setting: Check "Require conversation resolution before merging"
- Rationale: Ensures you've addressed any comments or notes left during review
- Impact: All PR comments must be marked as resolved before merging
- Solo Developer Note: Useful for tracking your own review notes and TODOs
- Setting: Check "Require linear history"
- Rationale: Maintains a clean, linear git history without merge commits
- Impact: Only allows squash merges or rebase merges for PRs
- Solo Developer Note: Recommended for cleaner history
- Rationale: Not practical for solo development
- Alternative: Use CODEOWNERS for documentation purposes only
- Rationale: Unnecessary when you're the only developer
- Note: You're already the admin/owner
- Rationale: You cannot review your own PRs
- Alternative: Set to 0 approvals if using PR workflow
Branch name pattern: main
☑ Do not allow force pushes
☑ Do not allow deletions
Branch name pattern: main
☑ Require a pull request before merging
☑ Require approvals: 0
☑ Dismiss stale pull request approvals when new commits are pushed
☑ Require status checks to pass before merging (if using CI/CD)
- Add your workflow status checks here
☑ Require conversation resolution before merging
☑ Require linear history
☑ Do not allow force pushes
☑ Do not allow deletions
-
Create a feature branch:
git checkout -b feature/my-new-feature
-
Make your changes and commit:
git add . git commit -m "Add new feature" git push origin feature/my-new-feature
-
Create a Pull Request:
- Go to GitHub and create a PR from your feature branch to
main - Review the changes yourself (or use GitHub Copilot for suggestions)
- Ensure all status checks pass (if configured)
- Go to GitHub and create a PR from your feature branch to
-
Merge the PR:
- If using 0 required approvals, you can merge immediately
- Choose merge strategy (squash recommended for linear history)
- Delete the feature branch after merging
-
Update your local main branch:
git checkout main git pull origin main
- Safety: Main branch is protected from accidental deletion or force pushes
- Clean History: Linear history with meaningful PR descriptions
- Documentation: Each PR serves as documentation for why changes were made
- Flexibility: You can still work quickly as a solo developer
- Best Practices: Prepares the workflow for potential future collaborators
- AI Assistance: GitHub Copilot can provide code review suggestions on PRs
As the repository owner/admin, you can always:
- Temporarily disable branch protection if absolutely necessary
- Override protection rules in emergency situations
- Modify protection settings at any time
However, avoid making exceptions habitual to maintain good development practices.
Review and update these settings:
- When adding collaborators to the repository
- When implementing CI/CD workflows
- When changing development workflow
- Quarterly as a best practice
Last Updated: 2025-11-16