user3341592
user3341592

Reputation: 1561

Don't display ^M (carriage return) in git grep output

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.

Upvotes: 5

Views: 410

Answers (1)

Saurabh P Bhandari
Saurabh P Bhandari

Reputation: 6762

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.

Upvotes: 5

Related Questions