git diff - show me line ending changes?
Solution 1:
First, make sure you're using the coloured output (e.g. with git diff --color
) and that you've enabled whitespace highlighting with (e.g.)
git config color.diff.whitespace "red reverse"
This might not work in all cases, however, as git
doesn't appear to highlight trailing whitespace for removed lines. To see whitespace that you've deleted, simply use
git diff -R
to put the whitespace on the 'added' side of the comparison, where it does get highlighted.
For more detail, see the answers at this SO question.
Solution 2:
You can see line-ending difference with the following command.
git diff | cat -v
Then "^M" is printed for CRLF (DOS) ending, nothing for LF (Unix) ending.
Apparently git diff is doing the right thing, printing CR and LF characters for CRLF ending. But because CR is consumed by the console, we cannot see it. By using cat -v, we can make it visible.