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.