这非常不直观:
C:\python-tdl\examples\termbox>git config core.autocrlf
false
C:\python-tdl\examples\termbox>git commit termbox.py
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
Aborting commit due to empty commit message.
根据core.autocrlf=false
的各种媒体,根本不应该进行换行转换。
在项目根目录中,我发现了.gitattributes
行:
# Auto detect text files and perform LF normalization
* text=auto
如果我发表评论,警告就会消失。问题 - 如何自动覆盖此.gitattibutes
设置?
答案 0 :(得分:3)
.gitattributes
会覆盖所有配置设置,因此无法覆盖;它是" overrider,"可以这么说。虽然您可以简单地删除该行,但这会导致其他开发人员的行为不一致。机器如果有core.autocrlf=true
。因此,最好的办法是将以下行添加到.gitattributes
:* -text
。这将禁用所有文件的CRLF处理。
答案 1 :(得分:1)
至少在现代版本的git中,.git/info/attributes
(或$GIT_DIR/info/attributes
)会覆盖.gitattributes
进行本地配置。
使用* !text
来使用core.autocrlf
的值,或者使用* -text
来强制不进行转换。
请参阅gitattributes
和the text
attribute的文档。
也请注意: core.eol
,the eol
attribute