Great git commit messages

Lately I read this great post on how to structure git commit messages so they are useful, clear and easy to read. But I really don’t want to find the post every time I commit, now do I?

For VSCode users

The projects I worked on after reading the post were mostly in Flutter. I program them using VSCode. There has to be a simple plugin for writing commit messages, right?

Right! This sweet extension was perfect for me. I chose the “form” option, which shows exactly what to fill where, including a dropdown for the various types with explanations on each one. Perfect!

gif showing how to use the VSCode plugin
Easy-Peasy

Look at those lovely messages:

clear and orderly git commit messages
Beautiful, isn’t it?

But: It doesn’t work with git submodules (it seemed to reference the wrong repo). Also, in the past few weeks I programmed also in Unity, Android Studio and STM32CubeIDE (don’t ask). I usually use Git Bash. So how to make git bash commits better?

Git Bash

The solution is using a git template. This opens the template each time you commit, providing you don’t use the “-m” option.

First, if you haven’t done so yet, setup your default message editor (I use vscode). Github has a list of many options here.

$ git config --global core.editor "code --wait"

Then create your template file (a great example is here). It can be anywhere you want. I put it in my projects folder: c/projects/gitmessage.txt

# Title: type(scope) description
# No more than 50 chars. #### 50 chars is here:####
# Types: fix(bug),feat(ure),perf(ormance),refactor,build,ci,docs,style,test# Remember blank line between title and body.
# Body: Explain *what* and *why* (not *how*).
# Wrap at 72 chars. ################################## which is here: ##
# One more blank line# Footer: fix/see also #123

Then you need to tell git to use it as a template:

git config — global commit.template /c/projects/gitmessage.txt

And remember to commit without the -m option:

git commit -a

or

git commit

git message template in VSCode
This is almost too easy

And you’re done!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Danielle H

Danielle H

7 Followers

I started programming in LabVIEW and Matlab, and quickly expanded to include Android, Swift, Flutter, Web(PHP, HTML, Javascript), Arduino and Processing.