- Article

go to article list

Mastering Commit Messages: Best Practices and Examples

Paolo Vincent Julian
Mastering Commit Messages: Best Practices and Examples banner

Mastering Commit Messages Banner


In the world of coding, tiny notes make a big impact. Meet commit messages – short, powerful, and often overlooked. These notes are the storytellers of your code’s journey.

Join us on a tour of commit messages. We’ll unveil their importance, highlight what not to do, share the gold standard, and equip you for smoother teamwork.

Let’s dive into this world where a few words shape the future of your code. Welcome to the realm of commit messages – where simplicity meets significance.

Table of Contents

  1. The Significance of Commit Messages
  2. Commit Message Standards and Best Practices
  3. Conclusion

The Significance of Commit Messages

In the realm of software development, precision and clarity are paramount. Enter the unassuming commit message, a brief yet essential element in the development process.

Why Do Commit Messages Matter?

Commit messages are the breadcrumbs that guide us through the labyrinth of code changes. They provide context, rationale, and a chronological roadmap of a project's evolution. When done right, commit messages enhance collaboration, simplify troubleshooting, and empower future developers to pick up where others left off.

Imagine a world without meaningful commit messages - a place where deciphering changes is a cryptic challenge and collaboration falters due to lack of understanding. Commit messages bridge these gaps, ensuring a seamless flow of information across the development landscape.

Bad Example:

commit 27a9b21
Author: Anonymous Coder <>
Date:   Fri Jul 15 2023

done some changes

Good Example:

commit c6f4d8c
Author: John Developer <>
Date:   Mon Aug 08 2023

feat // Add user registration functionality

This commit introduces a new feature - user registration. It includes API endpoints, database schema changes, and front-end form validation. This addresses issue #123.

Think of commit messages as historical markers

As your project grows and evolves, these messages become a timeline of decisions, improvements, and challenges. By crafting informative messages, developers gain the ability to track back in time, understand why certain decisions were made, and learn from past experiences.

It elevates Code Reviews

Code reviews are more than just scrutinizing lines of code. They are opportunities for learning, refining, and enhancing the codebase. Well-crafted commit messages make the review process smoother by offering a clear context for the changes, leading to more focused and effective reviews.

Commit Message Standards and Best Practices

Commit message standards can vary based on the development workflow and conventions of the project or organization. However, there are some common practices that can help make commit messages more informative and organized.

A popular convention for structuring commit messages is to use a prefix followed by a concise description of the change. This helps quickly understand the purpose of the commit. Here are a few common prefixes and their meanings:

1. feat: This is used for new features or functionality that have been added to the codebase.

# feat // Add user registration feature

2. fix: Used for bug fixes or resolving issues.

# fix // Fix validation error on login form

3. refactor: Used when code is refactored, but there are no new features or fixes introduced.

# refactor // Reorganize database schema

4. chore: For routine tasks, maintenance, or other non-code changes.

# chore // Update dependencies

5. docs: Used for documentation changes or additions.

# docs // Update README with new usage instructions

6. style: For code style changes, such as formatting or whitespace adjustments.

# style // Format code according to style guide

7. test: For adding or modifying tests.

# test // Add unit tests for new API endpoint

8. perf: Used for performance improvements.

# perf // Optimize database query for faster results

9. revert: Used to indicate a commit that reverts a previous commit.

# revert // Revert changes to user authentication

It's important to provide a clear and concise description after the prefix to explain the purpose of the commit. Try to keep the description under 72 characters to ensure readability in various contexts (such as Git logs or pull request summaries).

Providing a Detailed Description

Following the summary line, you have the option to provide a more comprehensive description of the commit. This is particularly useful when additional context or technical details are needed to understand the change. While there is no strict character limit for the description, keeping it concise and to the point is still advisable.


feat // Add user registration

Introduce user registration feature with API endpoints, database schema changes,
and front-end form validation. Resolves issue #123.


Remember, while these conventions are helpful, the most important thing is to maintain consistency within your project or team. If the project has established its own commit message guidelines, it's best to follow those conventions. Clear and informative commit messages contribute to better collaboration and codebase maintenance.

As you code on, remember: a single line speaks volumes. Commit messages become your legacy, leaving tracks for fellow coders. Your every commit molds the symphony of collaboration.

Thank you for joining us on this exploration. Keep coding, keep crafting, and keep changing the world—one commit at a time.




#version control

#commit messages

#coding standards

#development workflow

#coding tips

go to article list