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_TEMPLATE
file 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.