git opensource

How to write a good commit message

Git becomes like a secondary coffee for programmers in day-to-day work. And it comes with free services, not like paid one (coffee).

How to write a good commit message

Git becomes like a secondary coffee for programmers in day-to-day work. And it comes with free services, not like paid one (coffee). If you are new at Git, you can learn from my previous blog. Accidentally you will end up using free software once in a lifetime or day-to-day work. You are willing to contribute to that open-source software that has helped you for a long time. You will be forking, cloning their repository, and try to re-run the software. Now you see few commits on that program like initial commit, feat: remove x.

Hey, we are heading towards git commit. To find out the commit messages, all you need to hit down the below commands.

git log

Make sure you are in the current directory of open-source the project. You will see the short message. The developer might be the one who recently left that commit message during work.

New at git commit: command that takes a snapshot of your project at a specific point in time. Once you change your code, you will do “commit”. It’s about the message about the changes you were done. Once it completes, you can also revert the code to any version, once git saves the version of your code.

Another fellow worker will clearly understand what he/she has done in that assigned task. But, this is not for all such commit messages. There might be bad commits like I have during my beginning time.

Knowing how to write good commits in git is an underrated skill. It’s okay if you have been writing unusual git commits messages, it’s time to improve.

Git commits messages on the source code helps to communicate with each other. Developers spend a lot of time on the commit message to know the changes on their project or any opensource project. It’s necessary even if you are working alone it will make communication convention later.

Companies might have git commit standards as there are not any standards for git yet. Millions of developers follow out few standards of git commit through some guidelines you can also go with it. You can go with this basic guideline at least to write a good commit message in your project.

  • Always have error-free grammar words in the git commit message. It might lead to other meanings or might be confused about what the task was.

  • You might hurry and ignore the naming convention on git commit in your day-to-day work and move on. It might lead to trouble in the upcoming days. Spend more time crafting your commit message and naming conventions too.

  • Git commits message should include what you have done and why for changes in the code. A good commit message can help to explain what caused the problem and its consequences though most commit to fixing a problem.

  • Sometimes, it’s okay if the commit message is longer than you expect. The main goal is to write an understandable commit message. Keep in mind that when you note your git commit message, think about the new team and new people. It should be meaningful enough so that no one has to go burnout what the commit is all about. It might be difficult at the starting, and later on, you will have a habit of it.

Secret Tips: Always commit often for version controlling but not for a relationship.

So you might be interested in writing a git commit message. Clone your GitHub repository or someone else and try it out.

Run git commit commands with the -m option to write a commit message.

git commit -m "title" -m "description"

-m option is the title where it summarizes changes you have made. The next one is descriptions a summary of the changes. It should also explain what and why for your changes. Description is an optional one.

Since git also default uses the imperative to report is action. Few examples.

git merge master
git add index.html

The reason to prefer to have in the present tense is convincing the git what will be the next after the commit applied?

Try to write a commit message in an imperative mood. Example add an x feature modify an existing function remove base class It’s a bad practice we have been following since learning git.

git commit -m "fix bug"

You can add clarity to PRs raised and follow out below one.

git commit -m "feat: add registration -closes #123"

Also, I prefer you to use present tense instead of past or present continuous in your commit message. Good one

git commit -m "feat: this feature"

Bad one

git commit -m "refactoring: x module"

At some point, another developer needs to understand what has done, what to debug, or even go with the earlier stage. with the proper help of conversion, it will be much easier to see what you did.

  • feat: A new feature
  • fix: A bug fix
  • style: Additions or modifications related to styling only
  • refactor: Code refactoring
  • test: Additions or modification to test cases
  • docs: README, Architectural, or anything related to documentation
  • chore: Regular code maintenance

Some people also prefer to have capitalized the first word in the git commit message. Including emoji has become trending in a git commit message. It can benefit the commit message, an easy to grab and make the clean message.

  • ➕ : when adding a file or implementing a feature
  • 🔨 : when fixing a bug or issue
  • 💚 : when improving code or comments
  • ⚡ : when improving performance
  • 📜 : when updating docs or readme
  • 🔑 : when dealing with security
  • 🔁 : when updating dependencies or data
  • ✅ : when a new release was built
  • 👕 : when refactoring or removing linter warnings
  • ❌ : when removing code or files


git commit -m "🔨 FIX: error message for auth cases (#134)"

It will help the developer team to write good release notes to speed up the review process.



Little things always matter. You have to realize the essence of the commit message in your everyday workflow. You will also get to know whether the developer is a good collaborator or not.

It helps everyone and your team to keep the project clean and organized. Often commit message on some changes on your project is like check listing your room daily for cleaning. If you haven’t following the guidelines, I consider starting to use it now. Good luck.

On this page

Category under

git opensource

Share this post

You might also like

Subscribe to new posts