A Simple Hack to Write Better Commit Messages

According to Larry Wall laziness is one of the 3 virtues of a programmer, because it makes you document what you wrote so you don't have to answer so many questions about it.

While commit messages may not become part of the user facing documentation, they certainly are an important part of documenting development, especially when you work with other people.

Unfortunately, many developers interpret the laziness virtue not as intended and write pretty bad commit messages. Being guilty of that myself, I changed my git workflow to improve the usefulness of my commit messages, by adding the following shell alias:

alias gac='git add . && git commit -a'

Usually, I want to add or remove files from source code management, when I added or removed them from a project, but I tend to forget running git add .. But more importantly when I run gac an editor is opened to write my commit message.

Before, I simply wrote them directly on the command line being rather sloppy about spelling and grammar and sometimes just repeating previous messages by "abusing" command history.

With this little hack I get a shortcut for a longer command, I cannot simply repeat a previous message and just having an editor open makes me reason more about what I want to write, which is probably the most important part of it. If you write your commit messages directly on the command line, give it a try to see if they get better.


This post was written by Ramiro Gómez (@yaph) and published on . Subscribe to the Geeksta RSS feed to be informed about new posts.

Tags: git life hack software development

Disclosure: External links on this website may contain affiliate IDs, which means that I earn a commission if you make a purchase using these links. This allows me to offer hopefully valuable content for free while keeping this website sustainable. For more information, please see the disclosure section on the about page.


Share post: Facebook LinkedIn Reddit Twitter

Merchandise