Git:将所有文本文件默认为unix换行符 [英] Git: Default all text files to unix line breaks
问题描述
我知道在.gitattributes中设置了
*。txt eol = lf
也有这样的设置,所有的文本文件都默认为转换:
* text = auto
然而,当我尝试拥有所有我的文本文件为unix-line结尾,我注意到这并没有做任何事情:
* text = lf
这也改变了二进制文件:
* eol = lf
所以如何让文本文件和所有文本文件使用unix行结束?
编辑:这可以通过设置core.eol设置完成。我希望能用.gitattributes做到这一点,这是可能的吗?
试试这个
* text = auto!eol
然后在.git / config中设置core.eol = lf。
(编辑答案之前,我提出了一个选项* text = auto eol = lf但它不适用于这种情况)
I know there is setting in .gitattributes to have
*.txt eol=lf
and there is also this to have all text files default to conversion:
* text=auto
However, when I tried to have all my text files as unix-line endings, I noticed this doesn't do anything:
* text=lf
And this changes also binaries:
* eol=lf
so how to have only text files and all text files with unix line ends?
EDIT: this can be done by setting core.eol setting. I was hoping to do it with just .gitattributes, is that possible?
Try this
* text=auto !eol
and set core.eol=lf in .git/config.
(the answer is edited, before I proposed one more option "* text=auto eol=lf" but it doesn't work for this case)
这篇关于Git:将所有文本文件默认为unix换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!