Overview
Conventional Commits is a lightweight convention for commit messages that provides a structured and consistent way to communicate changes in software projects.
Key Benefits
- Clear, standardised commit history
- Automatic changelog generation
- Semantic versioning support
- Improved readability for humans and machines
Commit Message Structure
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types of Commits
feat
: New featurefix
: Bug fixdocs
: Documentation changesstyle
: Code formattingrefactor
: Code restructuringtest
: Test-related changeschore
: Maintenance tasksci
: CI/CD configurationperf
: Performance improvements
Example Commits
feat(auth): add two-factor authentication
fix(database): resolve connection leak issue
docs(readme): update installation instructions
Implementation Tips
Git Commit Template
Create a template in ~/.gitmessage
:
# <type>[optional scope]: <description>
# Types:
# feat: New feature
# fix: Bug fix
# docs: Documentation changes
# ...
Configure Git to use the template:
git config --global commit.template ~/.gitmessage
References
Tools
Best Practices
- Be concise and descriptive
- Use imperative mood
- Limit first line to 50 characters
- Explain "why" in the body, not "how"
Conclusion
Adopting Conventional Commits can significantly improve your project's documentation and collaboration.
Also, we use Conventional Commits internally at DeployHQ, of course :)