12 March, 2018

How to write a git commit message that won't disappoint your future self

Writing a good commit message is good practice. Why? Trying to understand why some old code is doing something is hard without context. You can help your future self and other developers with a good commit log.

Having well written code may not stop you from understanding code that seems complicated. Not because its badly written but because the problem its trying to solve is difficult in and on itself; This usually happens when the code is expressing business logic.

There are well-established conventions as to what makes a good git commit message. no need to re-invent the wheel. Just remember that a diff will tell you what changed, but only the commit message can properly tell you why.

Another question you may ask yourself is : What side effects does this change have?

The answer to this question in-particular can hint out problems where you are making too many changes in one commit or branch. One or two bullet points for related changes may be okay, but five or six are likely indicators that the commit is too large.

Great resources:

https://github.com/RomuloOliveira/commit-messages-guide

https://git-scm.com/book/en/v2

https://chris.beams.io/posts/git-commit/#seven-rules

body message example was referenced from: https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message