Git difftool and vimdiff

For the most part, I use TkDiff as the Git difftool when working under X Windows. TortoiseGit also has a nice GUI diff tool for when I do occassional work on Windows.

However, when working in a Linux "terminal" environment, your Git difftool choices seem to be limited to vimdiff. This is OK, but most of the color schemes under vimdiff are terrible.

I recommend using a vimdiff friendly color scheme like "greens" which is described here :

Here's how to set yourself up to use vimdiff as Git's difftool.

$ which vimdiff                          (ensure you have vimdiff installed)

$ git config --global diff.tool vimdiff  (set your difftool)

$ git config --list                      (confirm your difftool)

$ mkdir -p ~/.vim/colors                 (setup your vim color dir)

$ cd ~/.vim/colors

$ wget -O greens.vim

$ head greens.vim                        (confirm your new color file)

$ cd $GIT_REPO

$ git difftool                           (check out your new difftool setup)

(in Vim)
:color greens                            (change color and checkout greens)
:qall                                    (exit all windows)

$ vim ~/.vimrc                           (set greens as default vim color)

" color scheme of the moment:
syntax on
colorscheme greens

I found the color scheme "greens" to be the best with vimdiff, but here are some others that weren't too bad :

  • navajo
  • marklar
  • brown
  • clue
  • doorhinge

Couple more tweaks to this :

If you want to enable line numbering, put "set number" into your ~/.vimrc.

To make the line numbering be a grey color, put this into your color file :

hi LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE

There are 2 Comments