Enforcing Commit Message Format
Introduction
Section titled “Introduction”Consistent commit messages help automate changelogs and simplify code reviews.
Configure a Regex Rule
Section titled “Configure a Regex Rule”- Go to Settings > Repository > Push Rules.
- In Commit message must match this regular expression, add a pattern such as:
^(feat|fix|docs|style|refactor|test|chore): .+
- Save to enforce the rule.
Provide a Commit Template
Section titled “Provide a Commit Template”- Create a
COMMIT_TEMPLATEfile in the repository with the desired format. - Run:
Terminal window git config commit.template .gitmessage - Developers will see the template on each commit.
Best Practices
Section titled “Best Practices”- Follow Conventional Commits for compatibility with tooling.
- Include issue or ticket references in the footer.
- Reject empty or generic commit messages.