Commit messages saves life

Commit messages saves life

Writing Empathetic commit message

Yes, you read that right. Self explained commit messages saves time, therefore saves life.

What is a commit message?

A commit message literally tells what a line of code (either new or updated code) does.

A commit message explains what change you made to your project. It is greatly important to learn how to make a good commit message no matter if it is a personal or professional project.

Why do we have commit messages?

It is important to know that commit messages are not just ‘messages’ but does work as documentation.

Commit messages helps you document your progress of a feature or update and makes changes traceable in git.

Writing understandable commit message is an empathetic way of pushing your code. A well crafted commit message is a great way to communicate what change is made to a project so that other developers working on same have context of what is being updated and many times, your future self is at advantage.

How to write good commit messages

Different teams have different conventions and approach to writing commit messages. For clarity state, you may choose not to see this as a standard you must follow but best belief it’s a good approach.

I’ve seen many developers write commit messages like git commit -m 'made update', what update did you make? :)

Let's take a look at some approach to follow when writing commit messages.

When writing your commit message;

  • Make it clear and self explanatory.
  • Do not assume your code is explainable to all.
  • State the commit message type e.g. feat, refactor, test etc..
  • Should be short and ideally not more than 50 characters.
  • Do not end the commit message with a period (.).
  • Remove unnecessary extra characters.
  • Adhere to your team commit message convention.

A basic Example

feat: add new function to export csv file

feat: update input field validation mixin to check for whitespace

Conclusion

When writing your commit messages, try to be empathetic about it and never assume your code is explainable to all, you might be saving a developer hours of trying to understand a code block.

Thank you for reading.🤩