Introduction
Every software development team should adhere precisely to the Conventional Commits specification to maintain a structured commit history in Git. Conventional Commits offers a simple set of guidelines for producing an explicit commit history, which facilitates the development of automated tools on top of it. 3 minutes of reading the specifications might help you make your commit messages better.
According to the homepage Conventional Commits means:
A specification for adding human and machine readable meaning to commit messages. The Conventional Commits specification is inspired by, and based heavily on, the Angular Commit Guidelines.
Commit Message Structure
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
A very brief overview of the comment's purpose or content can be found in the <description>
field. The modification can be introduced in the <description>
field's title, and then more information about the change can be included in the <body>
field.
Conventional Commits Type
Some of the most useful types are:
Syntax | Description | Example |
feat | to add a new feature | feat: add header component |
fix | bug fixes | fix: undefined issue |
docs | for documentation | docs: updated readme.md file |
style | changes to the code that do not affect the meaning ((white-space, formatting, missing semi-colons etc.) | style: improve main page style |
refactor | a code change/cleanup that neither fixes a bug nor adds a feature | refactor: refactor x function |
perf | any code change that improves performance | perf: code-splitting for best performance |
test | automated tests | test: add missing test for X controller |
build | changes to affect the build system or external dependencies (yarn, npm, serverless etc.) | build: switch from npm to yarn |
chore | changes related to code cleanup | chore: remove unused components |
revert | to revert an accidental commit | revert: revert commit x |
ci | changes to CI configuration files and scripts | ci: add unit testing using Jest in the ci steps |
bump | managing the dependency versions | bump: migrate from vue 2 to vue 3 |
BREAKING CHANGE:
a commit that has a footerBREAKING CHANGE:
, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
Conclusion
Conventional Commits can aid with CI/CD pipelines by integrating nicely with automated tools like husky and reviewdog in addition to keeping a cleaner git commit history. So stop waiting and begin utilizing it right away! 😃