* text=auto eol=lf
我想要准确地了解这样做.
第一部分是text = auto.从documentation:
This ensures that all files that Git considers to be text will have normalized (LF) line endings in the repository.
重要的部分是Git仅对其作为文本文件检测到的文件进行归一化.
但是,我不确定eol = lf部分.我会认为它也将仅对文本文件进行规范化,但是在文档中找不到它的支持,当我们的PNG文件被归一化时,我们有一个实例,使它们无效.
解决方法
相关:feature proposal on Git mailing list
* text=auto
This will correctly normalize text files in the repo. However,the
second part (LF forcing on checkout) cannot be achieved easily today
because addingeol=lf
will unfortunately process binary files too.
The only solution today is to mark certain types for conversion (e.g.,
*.txt eol=lf
) or,inversely,mark certain types as binary (e.g.,
*.png binary
).Both of these suffer from the same issue: the specific file types must
be listed explicitly in the.gitattributes
file,which means that
either the types must be known ahead of time or all developers must
remember to update the.gitattributes
file every time a new file type appears in the project. Which they won’t.