When I execute git show
on an existing commit, the output is full of highlighted whitespace errors; especially trailing whitespace and carriage returns. It's very annoying, since this is someone else's old commit that was merged a long time ago, so it's not like I can do anything about it now.
I can suppress these with the right arguments to e.g. git config --global core.whitespace cr-at-eol
. That works fine.
The thing is, I want those warnings with git diff
. I want to know before I check in a file with broken whitespace. I just don't want to see the warnings on commits I can't change anyway.
Is there a way to set cr-at-eol
, etc. just for git show
?
You can run this command to have the expected behaviour:
git -c core.whitespace=cr-at-eol show
git -c
allows you to override configuration parameters for the current command (it's not saved in the config).
If you want to read more about git -c
: https://git-scm.com/docs/git#Documentation/git.txt--cltnamegtltvaluegt