admin管理员组文章数量:1191728
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
?
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
?
2 Answers
Reset to default 2You 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
The config parameters are a persistent way to set a number of flags which can also be set with regular command line arguments.
For example:
git show --no-cr-at-eol ...
These options are listed in git help show
If you are looking for a shortcut to use these options repeatedly, you can set an alias:
# run once:
git config --global alias.view "show --no-cr-at-eol"
# you can now type:
git view ...
本文标签: Suppress whitespace warnings in git show but not git diffStack Overflow
版权声明:本文标题:Suppress whitespace warnings in git show but not git diff - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738453576a2087629.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
--ignore-space-change
would work for your case. – Guildenstern Commented Jan 24 at 8:16