To hide the awful ^M
characters from git diff
, one has to config:
[core]
whitespace = cr-at-eol
But they are still displayed in git grep
output.
How to solve that?
EDIT -- The grep I'm running is:
git grep -i --line-number --break --heading -C 1 <PATTERN>
in Cygwin (on Windows) with less -R
as pager.
Quoting this from a similar question (which is related to git diff
),
Change the core.pager to
"tr -d '\r' | less -REX"
You can either change this configuration globally like this,
git config --global core.pager "tr -d '\r' | less -REX"
or just use it once for git grep
,
git -c core.pager="tr -d '\r' | less -REX" grep -i --line-number --break --heading -C 1 <PATTERN>
User Jason Pyeron provides a thorough explanation here.