DEV Community

Cover image for Write Clear and Meaningful Git Commit Messages
Ashish Patel
Ashish Patel

Posted on • Updated on

Write Clear and Meaningful Git Commit Messages

There are no strict rules for writing commit messages but When working on a project on GitHub, it's important to communicate clearly and concisely about the changes you've made. One way to do this is through the use of keywords in your commit messages.

These keywords, or labels, help to indicate the nature of the changes and make it easier for others to understand the context of your contributions.

Here are some common keywords and what they indicate:

FEAT: Use this keyword to indicate that you are committing to a new feature.

"FEAT: Add new login functionality."

FIX: Use this keyword to indicate that you are committing a fix for a specific problem or issue.

"FIX: Fix bug causing crashes on certain devices."

STYLE: Use this keyword to indicate that you are making changes to the style or formatting of the code, but not its functionality.

"STYLE: Update indentation in main.js."

REFACTOR: Use this keyword to indicate that you are making changes to the code that improve its structure or organisation, but do not add new features or fix bugs.

"REFACTOR: Refactor the code to improve readability."

TEST: Use this keyword to indicate that you are adding or updating tests for the code.

"TEST: Add new unit tests for login functionality."

CHORE: Use this keyword to indicate that you are making changes to the build process or other tasks that are not directly related to the code itself.

"CHORE: Update dependencies in package.json."

PERF: Use this keyword to indicate that you are making changes to improve the performance of the code.

"PERF: Optimize image loading for faster performance."

CI: Use this keyword to indicate that you are making changes to the continuous integration process.

"CI: Fix issue with test pipeline on Dashboard CI."

BUILD: Use this keyword to indicate that you are making changes to the build process.

"BUILD: Add new script for building the production version of the app."

By using these keywords in your commit messages, you can help to make your contributions more clear and more understandable to others. However, it is important to note that these are just suggestions and not all projects use them, it's important to check the project's documentation to see if there are any specific guidelines you should follow.

In summary, clear and concise commit messages are a key aspect of good development practices. Using keywords in your commit messages can help to indicate the nature of the changes you've made, making it easier for others to understand and review your contributions.

My Other Blogs
BEM Methodology for CSS - A Guide for Developers

Top comments (33)

Collapse
 
derlin profile image
Lucy Linder • Edited

There are no strict rules, but there are conventions!

I am surprised not to see any reference to conventional-commits which is the actual specification behind this practice. The spec, however, defines lowercase types (feat VS FEAT).

There is also a bit more to it (footers, breaking changes).

For anyone interested, I strongly suggest to read the spec and the angular conventions directly!

Collapse
 
tlylt profile image
Liu Yongliang

conventional-commits is definitely the more popular/standard way to do this, especially useful for (auto) release management :)

Collapse
 
rcls profile image
OssiDev • Edited

Also known as "semantic commits". When I started with this there were only feat, fix, doc and test. Later refactor. Now it seems these are growing every year.

Collapse
 
spo0q profile image
spO0q 🐒🎃

Simple but efficient technique! Congrats.

Although, I would add one advice that I find critical:

Choose a naming convention and stick with it. It's important teammates use the same pattern. Best way to ensure that it pair programming with new members, but you can also document it.

Collapse
 
derlin profile image
Lucy Linder

Or simply use an existing convention, like conventional-commits which is actually the spec this article sums up 😉

Collapse
 
ashishxcode profile image
Ashish Patel

Thanks will have a read 🙌

Collapse
 
spo0q profile image
spO0q 🐒🎃

not all organizations will follow that framework.

Collapse
 
husseinkizz profile image
Hussein Kizz

I installed it but I like commiting from terminal, I don't think it was applicable then!

Thread Thread
 
derlin profile image
Lucy Linder

What do you mean install? This is just a convention you can decide to follow, nothing to install.

There are many tools built around the convention, yes, but you don't have to use them. I also commit from the command-line, the idea is just to follow the convention when writing the commit message (like shown in this article).

Thread Thread
 
husseinkizz profile image
Hussein Kizz

Yes I like the article and I will be following it on wards, perhaps to make it reachable I will create a Convention file in project to remind me until I can do it without reference. But up there I was responding to the conventional commits extension suggestion. Anyway thanks!

Collapse
 
the_riz profile image
Rich Winter

Lately, I've been using emoji to categorize my messages. Though I leave it to you to pick which you would use for the keywords above..

👍🏼👌🏼✍️💅🌲🕸️🐛👾🎛️🪠🔧🔨⚒️🛠️⛏️🔗🚫🆕🆙🆗🚮⚕️🏁🎨🚛🚀

Collapse
 
tlylt profile image
Liu Yongliang

Just want to make sure, is it “ REACTOR” or “REFACTOR”?

Collapse
 
ashishxcode profile image
Ashish Patel

Thanks, Will fix it

Collapse
 
gbhorwood profile image
Info Comment hidden by post author - thread only accessible via permalink
grant horwood

FIX: refactor

Collapse
 
codewithbernard profile image
Bernard Bado

This is very helpful. Commit messages are a lot of time source of truth.

Collapse
 
pterpmnta profile image
Pedro Pimienta M.

Good ideas.

Collapse
 
neumatic_78 profile image
neu-ma-tic

haha keyboard go brrrrr

Collapse
 
ashishxcode profile image
Ashish Patel

Haha 😅

Do share this blog with your team

Collapse
 
flimtix profile image
Flimtix

I like this schematic naming! Your article sums it up perfectly. 👍
Personally, though, I use emojis instead of prefixes because they stand out more.

Collapse
 
ashishxcode profile image
Ashish Patel

Yeah not doubt in that, but I feel it's about the preference

Collapse
 
sehgalspandan profile image
Spandan Sehgal

Amazing content, thanks for sharing.

Collapse
 
jwp profile image
John Peters

Crazy simple. Good... thanks...

Collapse
 
ashishxcode profile image
Ashish Patel

I hoped it help you 😌

Some comments have been hidden by the post's author - find out more