'Is it possible to make --word-diff default in git diff, git gui, gitk

Is it possible to set an option that git diff is always using --word-diff=color whenever displaying diffs?

I know that there are command line arguments for gitk, git-gui and git diff, but are there config options I can set globally?

I found that this works for git-gui: Adding this to .gitconfig works for guid

[gui]
    diffopts = --word-diff --color-words

But using this, I can not actually pick anything anymore. I get "diff fails to apply" whenever I want to commit any line or chunk.



Solution 1:[1]

If you frequently invoke git diff you may define a git alias.

$ git config [--global] alias.df "diff --word-diff=color"

And then use git df instead of git diff.

Solution 2:[2]

You can set the options you want to use in git gui with gui.diffopts. For example, for word diff:

git config --global gui.diffopts --word-diff

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paul Roub
Solution 2 Jonah Graham