这是很不直观的:

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设置?

最佳答案

.gitattributes会覆盖所有配置设置,因此它实际上不能被覆盖;可以这么说,它是“压倒一切”。尽管您可以简单地删除该行,但是如果其他开发人员的计算机具有core.autocrlf=true,这将导致其行为不一致。因此,最好的选择是将以下行添加到.gitattributes中:* -text。这将禁用所有文件的CRLF处理。

08-27 06:44