Conventional Commits: Simplify Your Project History and Automate Tasks
Conventional commits are a standardized way to format commit messages in software development. The goal is to make it easier to understand the history of a project and automate certain tasks. Conventional commits follow a specific syntax, allowing tools to generate changelogs, version numbers, and more automatically.
Structure of Conventional Commits
A conventional commit consists of a type, scope, and subject separated by a colon.
For example:
feat: add payment feature
The feat
indicates the type of commit, in this case, a new feature.
fix: improve performance in dashboard module
Here, the type is fix
(a bug fix), the subject is improve performance in dashboard module
, and the scope is dashboard module
. The scope is optional for a conventional commit
Types of commits
There are several types of commits specified in the conventional commits specification:
feat
: a new featurefix
: a bug fixdocs
: documentation changesstyle
: formatting, missing semi-colons, etc.refactor
: code changes that do not fix a bug or add a featureperf
: changes that improve performancetest
: adding or updating tests
Benefits of using this
Using conventional commits can have several benefits for your team. First, it makes it easier to understand the history of a project, as the commit messages provide clear and concise information about the changes made. This can be especially useful when reviewing code or trying to understand why a particular change was made.
Second, conventional commits allow for the automated generation of changelogs and version numbers. Many tools, such as semantic-release, use the commit messages to determine the next version number and generate a changelog. This can save your team time and effort.
Take a look at this article about automating releases and publishing packages to the NPM registry. Take a look at the release.yml
workflow alone to get an understanding to automate releases with conventional commits
Final words
Finally, Adopting conventional commits can help improve the organization and maintainability of your codebase. It's a simple change that can have big benefits for your team. If you're not already using conventional commits, consider giving them a try on your next project.
I hope you are clear with conventional commits and their use cases. Thanks for reading