I like the output formatting of git diff
. The color and the +
/-
representation of changes between lines is easier to read than GNU di
GNU diff
has a --color
option since version 3.4 in late 2016 according to this answer on the Unix SE. That alongside -u
should be enough to mimic the output of git diff
:
diff -u --color=always file1 file2 | less -r
--color
must be always
when used in a pipe, auto
will turn off color in pipes.
I've only tried this with Git Bash on Windows, where less -R
would only color the first line of a hunk. less -r
fixed it for me in that case.