Martin Vegter
Martin Vegter

Reputation: 527

git diff: specify different highlighter as commandline option

I have this in my .gitconfig:

[pager]
    show = diff-highlight
    diff = diff-highlight

When I do git diff, thendiff-highlight is used for color highlighting.

How can I specify on the command line a different highlighter? I want to use diffr, without changing the default in .gitconfig.

I tried git difftool --tool=diffr but this does nit work, and it seems this is different from what I want.

Upvotes: 2

Views: 145

Answers (1)

phd
phd

Reputation: 94407

Set environment variable PAGER or GIT_PAGER for the command:

GIT_PAGER=diffr git diff

Or set the config value at the command line once:

git -c pager.diff=diffr diff

Upd. The following command creates an alias:

git config --global alias.diffr '!GIT_PAGER=diffr git diff'

The alias can be used with parameters:

git diffr HEAD~

Upvotes: 3

Related Questions