Skip to main content
  1. Posts/

Show Git Diff When Doing Git Commit

··260 words·2 mins·
Git Nvim Vim Diff
Table of Contents

I saw on YouTube a video made by TJ DeVries on how to contribute to the neovim project. There is a scene where he commit via git commit, and whoa, a Neovim instance appeared with three split, with top left the commit message area, top right the git-status area, and on the right the git-diff info, which is really cool.

A little background, the default git commit only shows status info without the diff info. For commit related to changes in several files, it is difficult to remember all the diffs and summarize them in the commit message.

I searched a bit and figured out how to do it in Neovim.

Native git options
#

First, make sure that commit message editor is set to Vim or Neovim:

git config --global core.editor nvim

We can add --verbose/-v option when commiting to show the diff info:

git commit -v

Better, to set it permanently (for Git version above 2.9.0):

git config --global commit.verbose true

With the above config, the diff info will be shown below the status info. For short diffs, it is acceptable, while for longer diffs, it is still not easy to check.

Using a plugin
#

committia.vim is a plugin that re-arrange the commit window for easier writing of commit messages. When you run git commit, it will automatically show a three-split window like what is shown in the title image.

References
#

Related

Git Learning Notes (2)
··410 words·2 mins
Git Git Vim
Git Learning Notes (1)
··701 words·4 mins
Git Git Diff
Generating Table of Contents for Markdown with Tagbar
··355 words·2 mins
Note Nvim Markdown Tags Vim