The word-diff suggested in the other answer isn’t exactly what gitlab/github do. To get same effect, you can use diff-highlight script that is distributed with git.
-
First find path to
diff-highlightscript. It varies between systems, and is not usually in $PATH. You can find it with your package manager, for example:- Fedora:
rpm -ql git | grep diff-highlight - Debian/Ubuntu/Mint:
dpkg -L git | grep diff-highlight - Archlinux:
pacman -Ql git | grep diff-highlight
- Fedora:
-
Now, execute the following two commands, which will add to your
~/.gitconfigthe necessary settings:$ git config --global core.pager 'perl /usr/share/git/diff-highlight/diff-highlight | less' $ git config --global interactive.difffilter 'perl /usr/share/git/diff-highlight/diff-highlight'I’m using
perlhere instead of calling the script directly because some distros, it seems, do not set executable bit on the script. IMO this is a package bug which should be reported. Anyway, this answer should work regardless.
Now log, diff, show commands should show difference word-by-word. Screenshot:
