DEV Community


How to use terminal to make git diff beautiful

Updated on ・1 min read

Hi, terminal folks!

There is the word diff feature in git.
Let's activate it now!

First, my git version is this.

$ git version
git version 2.21.0

It is essential to make a diff-highlight binary file.
Then move it to executable path or create a symbolic link for same purpose.
However, initial state of the binary is different depends on each linuxs.
there are 3 patterns as far as I know.

  1. a binary exists with an executable permission
  2. a binary exists with a not-executable permission
  3. there is a make file instead of a binary

I write just for option#3. If your initial state is #1 or #2, please make sure it works by reading below. I guess you can do it.

cd /usr/share/doc/git/contrib/diff-highlight/
sudo make
sudo ln -s /usr/share/doc/git/contrib/diff-highlight/diff-highlight /usr/local/bin/diff-highlight
sudo chmod +x /usr/share/doc/git/contrib/diff-highlight/diff-highlight

At last, edit your ~/.gitconfig file

    pager = diff-highlight | less -r

Discussion (0)

Forem Open with the Forem app