Construct better commit messages using VIM


Jescart / February 01, 2019

How to construct a better commit message using Vim editor?

The purpose of this tutorial is to teach you to create better commit messages so the reviewer can do a more thorough review.

At first, It is confusing to use the Vim editor, but I did some research and documented a step by step process to do it:

git add .

to add your changes to your upcoming commit.

Step 2: Open a Vim editor.

git commit

If your encounter
error: There was a problem with the editor 'vi'.run this in your command line

git config --global core.editor /usr/bin/vimand do it again.

Use the git commit command without any flags. The VIM editor will open.

git commit

By pressing the i key (Insert mode) on your keyboard you can now start typing and create a better commit message. So your goal here is to write a message that explains well your changes.

VIM editor

Once you are done, press esc key (exit insert mode) then type :wq and press enter to save your commit message and close the Vim editor.

Step 3: Lastly push your commit

git push origin [branch_name where your commit at]

On GitHub this commit will looks like this:

Github commit preview