DEV Community

Cover image for Few Tips for writing better commit messages
Lakh Bawa
Lakh Bawa

Posted on Edited on

Few Tips for writing better commit messages

I was reading the source code of Vuejs 3 just a few minutes back and found a commit message template used by Evan You. It looked interesting to me. check and try to apply it in your workflow, if you like it.

Prefixes to add before commit messages:

test: (working on tests)
refactor: (refactoring the code)
fix: (doing some bug fixes
feature: (adding the new feature) 
build: ( adding some package or something required when building)
types: (adding the variable type, interface or something like that)
style: (some CSS or style improvement that does not affect the core functionality)
docs: (wrote some documentation or code comments)
wip: (full form: work in progress, when something is under work in progress usually some complex stuff that has to be done in parts)

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung

example commit message:

fix: fixed title not defined on the jobs page

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung

Improved

One more idea I learned from Angular Contribution Guide. we can improve our commit messages further to include the area of changes.

After Commit prefix like fix or refactor you can include the module or feature in brackets. just like following.

fix(auth): fixed the refresh token issue

refactor(registration): Improve the performance by putting email sending logic in queue
πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung

Thanks for reading.

Top comments (9)

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
suckup_de profile image
Lars Moelleken •

I add a more simple prefix:

[*] = phpdoc, text changes,... (nothing will be break)
[~] = refactoring (nothing should be break)
[+] = new feature, fix old feature (maybe I break it)
[!] = break change
[!!!] = security fix

github.com/voku/dotfiles/wiki/git-...

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
bawa_geek profile image
Lakh Bawa •

good idea

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
incrementis profile image
Akin C. •

Hello Lakhveer Bawa,

thank you for your article.
For me this is good information in combination with Rubin's article entitled "How to write meaningful and better commit messages".
Especially the additional "TYPES" refactor and wip are useful in my case.

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
bawa_geek profile image
Lakh Bawa •

great

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
nschelin profile image
nschelin •

Hi! Great info :) Any chance of a link to the source template?

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
bawa_geek profile image
Lakh Bawa • • Edited

Hi, thanks

here is list of commits from Evan you where I got this idea.

github.com/vuejs/vue-next/commits/...

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
nschelin profile image
nschelin •

Awesome. Thank you!

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
evanboissonnot profile image
Evan BOISSONNOT • • Edited

Hello !

You can use this, to your projects, very helpfull !

commitizen.github.io/cz-cli/

πŸ† Live Soccer TV: bawa geek/few tips for writing better commit messages ie - Jadwal Siaran Langsung
 
bawa_geek profile image
Lakh Bawa •

absolutely love the idea behind the tool, but I believe we should not rely on tools too much. Every new tool in the workflow, adds more complexity into dev life