本文介绍了在Windows中覆盖.gitattributes text = auto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  C:\python-tdl\examples\termbox> git config核心。 autocrlf 
false

C:\ python-tdl\examples\termbox> git commit termbox.py
警告:LF将被CRLF替换为examples / termbox / termbox.py。
该文件将在工作目录中具有其原始行结尾。
警告:LF会在examples / termbox / termbox.py中被CRLF取代。
该文件将在工作目录中具有其原始行结尾。
警告:LF会在examples / termbox / termbox.py中被CRLF取代。
该文件将在工作目录中具有其原始行结尾。
由于提交消息为空而中止提交。

根据各种媒体报道 core.autocrlf = false 根本不应该换行转换。

在项目根目录中,我发现 .gitattributes

 #自动检测文本文件并执行LF标准化
* text = auto

如果我评论它,警告消失。问题 - 如何自动覆盖 .gitattibutes 设置?

> .gitattributes 会覆盖所有配置设置,所以它确实不能被覆盖;可以这么说,它是覆盖者。虽然您可以简单地删除该行,但如果其他开发人员的机器具有 core.autocrlf = true ,则会导致行为不一致。所以最好的办法是将以下行添加到 .gitattributes * -text 。这将禁止所有文件的CRLF处理。


This is pretty unintuitive:

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.

According to various media with core.autocrlf=false there should be no linefeed conversion at all.

In project root I discovered .gitattributes with the line:

# Auto detect text files and perform LF normalization
* text=auto

If I comment it, the warning goes away. The question - how can I override this .gitattibutes setting automatically?

解决方案

.gitattributes overrides all config settings, so it really can't be overridden; it is the "overrider," so to speak. While you can simply remove the line, this will cause inconsistent behavior on other developers' machines if they have core.autocrlf=true. So the best bet would be to add the following line to .gitattributes: * -text. This will disable CRLF processing for all files.

这篇关于在Windows中覆盖.gitattributes text = auto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 03:58