How to customize git diff to spot changes faster

diff-so-fancy is a tool that helps you to customize your diff view

git diff is one of the most useful features in git. Customizing diff will make your life easier.

Diff-so-fancy is the git tool that helps you to make good looking diffs. This tool helps you to spot the differences without any human error.

You can view the package in this repo

Let’s see that in-depth

Installation

Diff-so-fancy is available in brew, npm and also as a package for Debian Linux

brew install diff-so-fancy

npm i diff-so-fancy --global

Usage

I will explain a few ways of using diff-so-fancy. You can choose your way of doing it.

Be default, diff-so-fancy will never change any default diff options. You should explicitly mention it.

git diff | diff-so-fancy

The above command will use diff-so-fancy to display the difference.

If you want to make diff-so-fancy as default diff viewer, you can use

git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"

Now you can just use git diff to use diff-so-fancy.

Now for some reason, you may wish to use the default git diff to view the change even after setting diff-so-fancy.

In that case, you can use

git --no-pager diff

The above command will bypass diff-so-fancy. So the default diff view will be used.

Remove diff-so-fancy from the default option

To remove diff-so-fancy from the default git diff, you can set the pager as

git config --global core.pager 'less'

Git uses a pager to display the content. Pager is used in commands like git-diff, git-log. By default, a pager called less is used by Git.

So in the above command, I have set the default pager to Git.

diff-so-fancy comes with few options. You can see that in the repo.

That’s it for today :)

See you next week :) :)

And remember if you want me to cover some specific topics, you can reply to this email. I’m running this newsletter for you and I’m always open for ideas :) :)