Discussion on: Any rules, tips and tricks for commit message

zizaco profile image

From the CONTRIBUTING.md of our current project:

Ideally, the commits should be as small and descriptive. As the user stories, the commits should ideally clarify what is it's purpose. A way to do that is to answer to this 4 questions:

  • To which story does it belongs? (story id)
  • How does it address the issue? ("updated", "added", "implemented", "removed", etc)
  • Why is this change necessary? ("to", "in order to", )
  • What side effects does this change have? ("from now on ...")

With this in mind, no commit message should be less than 50 characters and should contain more than one line. This is not a strict rule, but by following the structure:

<id> - <how> <why> <side-effects>

It becomes easy to write more than 50 characters. For example:

h3C2s4HX - Updated user/User entity in order to properly validate it's attributes.
From now on if the validation is made before saving it to the database.

"Having a story in your git log will make a huge difference in how you and others perceive your project. By taking great care in commit messages, as you do in your code, you will help to increase overall quality." - Caleb Thompson