Enforcing Branch Naming Conventions
Introduction
Section titled โIntroductionโBranch name conventions help keep history readable and enable automated workflows. GitHub can enforce naming patterns through branch protection rules.
Define Naming Patterns
Section titled โDefine Naming PatternsโCommon prefixes include:
feature/
for new featuresbugfix/
for fixeshotfix/
for urgent patches
Configure Branch Protection
Section titled โConfigure Branch Protectionโ- Go to Settings > Branches.
- Click Add rule and set the Branch name pattern using glob syntax, e.g.
feature/*
. - Enable required checks such as status checks or approvals.
- Save the rule; pushes to branches matching the pattern must satisfy the protection settings.
Example
Section titled โExampleโTo enforce feature branches to match feature/*
, create a rule with pattern feature/*
and enable Require pull request before merging.