Enforcing Branch Naming Conventions
Introduction
Section titled βIntroductionβConsistent branch names clarify purpose and automate workflows. GitLab push rules let you reject branches that do not match a regular expression.
Configure Branch Naming Rules
Section titled βConfigure Branch Naming Rulesβ- Go to your project and open Settings > Repository.
- Expand Push Rules.
- In Branch name pattern, enter a regex such as:
^(feature|bugfix|hotfix)\/.*
- Click Save changes.
Regex Examples
Section titled βRegex Examplesβ^feature\/β require branches to start withfeature/.^(bugfix|hotfix)\/JIRA-\d+β include a ticket ID.
Best Practices
Section titled βBest Practicesβ- Document branch patterns in
CONTRIBUTING.md. - Apply rules at the group level for consistent enforcement across projects.
- Combine with protected branches to guard main lines of development.