Git:使用git钩子将回车\r转换为新行\\\<br/>? [英] Git: convert carriage return \r to new line \n with git hook?
问题描述
有没有办法编写一个git钩子来转换所有的 \r\\\
至
\\\
?
注意我之前没有使用过git钩子,所以稍微额外的手持可能会有很长的路要走:
div>最简单的事情是设置 core.autocrlf
改为false 。
(这样Git不会做任何转换,并且会保持eol不变)。
在unix方面, core.autocrlf
设置为true可以帮助恢复正确的eol。
由于 mathepic 在评论中提及,并且作为在这个SO回答描述,因为Git1.7.2,你可以使用 core.eol
(本地),将 core.autocrlf
保留为false。
否则,您可以使用 gitattributes 文件的文本驱动程序或过滤器驱动程序。
不需要挂钩。
A fellow coder uses a Windows computer that is putting carriage returns everywhere in our source.
Is there a way to write a git hook that converts all \r\n
to \n
?
Note I haven't used git hooks before, so a little extra hand-holding might go a long way :)
The simplest thing is to set core.autocrlf
to false on The Windows side.
(that way Git won't do any conversion and will keep the eol untouched).
On the unix side, a core.autocrlf
set to true could help restore the proper eol.
As mathepic mentions in the comments, and as I described in this SO answer, since Git1.7.2, you can use core.eol
(to native), keeping core.autocrlf
to false.
Otherwise you can use a text driver or a filter driver with gitattributes
files.
No hooks needed.
这篇关于Git:使用git钩子将回车\r转换为新行\\\<br/>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!