Skip to content
GitHub Twitter

Improving Commit Messages with Conventional Commits

Have you ever looked at a commit message and struggled to decipher what it meant? If so, you're not alone! Commit messages are essential for understanding changes to a codebase, but poorly written messages can lead to confusion and difficulty debugging.

This post covers the concept of conventional commits, a strategy for crafting clear and concise commit messages that make it easy to understand what changes were made and why.

Conventional Commits 101

So what exactly are conventional commits? At their core, they consist of three key pieces:

  • Type: What kind of change was made? Examples include docs fix, feature, performance, style, refactor, test, and chore.
  • Scope: Which part of the codebase was affected by this change?
  • Subject: A brief message that summarizes the change in 15-20 characters.

Here's an example of what a conventional commit might look like: feature(style): change background color. This message tells you that a new feature was added that affected only the styling of the code, specifically the background color.

By using conventional commits consistently across your codebase, you can make it easy for anyone to find a fix for an issue or understand what changes were made in a given commit. Plus, it's a great way to encourage effective communication between teams and avoid confusion.

Why You Should Use Conventional Commits

Still not convinced that conventional commits are worth the effort? Here are a few reasons why they're a great choice for any development project:

  • Easy to search and find: By using clear, descriptive commit messages, you can quickly find the exact change you're looking for in your version control system.
  • Improved communication: When working with others, conventional commits make it easier to understand what changes were made and why.
  • Better debugging: When a user reports a bug, you can quickly search for the relevant commit and see what changes were made to identify the issue and fix it.

Using the VS Code Extension

Ready to start writing conventional commits? I recommend using the VS Code extension for even easier integration. The conventional commits extension allows you to select the type of change you're making, choose a scope if necessary, and add a brief description of the change – all with the click of a button.

Once you've committed your changes, you can easily see the resulting commit message and understand exactly what changes were made. And if you ever need to search for a specific commit, you can quickly find it based on the information in the message.

Conclusion

Commit messages may seem like a small detail, but they play an essential role in effective development. By using conventional commits, you can make it easier for yourself and others to understand changes to your codebase and collaborate more effectively.