Configuration
How It Works
This ruleset implements three important branch protection patterns:- Branch Naming Convention: Ensures all feature branches follow a consistent naming pattern
- Main Branch Protection: Applies stricter validation for PRs targeting the main branch
- Feature Branch Flow: Enforces a workflow where feature branches must target develop, not main
Extending the Example
Branch Prefixes by Type
Enforce different branch prefixes based on the type of change:Jira Integration
Enforce Jira ticket references in branch names:Team-Specific Branches
Apply different naming conventions for different teams:Release Branch Restrictions
Enforce special rules for release branches:Branch Protection Strategy
Implement a complete branch protection strategy with these components:GitHub Branch Protection Settings
First, set up GitHub branch protection rules for important branches:- Go to Repository Settings → Branches → Branch protection rules
- Add rules for
main
anddevelop
branches:- Require pull request reviews
- Require status checks to pass
- Restrict who can push
Complementary Ruleset Configuration
Then use Rulesets to add more sophisticated validations:Benefits
- Consistency: Enforces consistent branch naming across the team
- Quality Control: Applies appropriate validation based on branch type and target
- Workflow Enforcement: Ensures your Git workflow is followed correctly
- Automated Feedback: Provides clear guidance when conventions aren’t followed
- Reduced Human Error: Prevents accidental merges to protected branches