2015-06-22 76 views
2

这是很直观:覆盖.gitattributes文本=自动在Windows

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

回答

3

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

+1

如果GIT有一些选项将EOL转换完全关闭,无论.gitattributes文件如何,那将会很好。在我的情况下,.gitattributes文件由RE维护,我无法更改它,但我绝对希望只使用LF在我的PC上存储所有文件。 –

+0

非常感谢。我花了很多年的时间与设置了'* text = auto'的快速导出进行对抗。这个伎俩。如果可以的话,我会投票10次! – spikyjt

+0

@AndreiLED您可以通过编辑/添加.git/info/attributes来覆盖此回购。优先顺序是全局配置 - > .gitattributes在dir - > .git/info/attributes中(即后者采用最高优先级并覆盖其他优先级)。参考这里:http://git-scm.com/docs/gitattributes – spikyjt