gitattributes中的`* text = auto eol = lf`会做什么?

前端之家收集整理的这篇文章主要介绍了gitattributes中的`* text = auto eol = lf`会做什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们在.gitattributes文件中有这个:
* 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文件被归一化时,我们有一个实例,使它们无效.

有没有像上面这样的设置,基本上会说“做文本文件的双向规范化,并保留二进制文件”?

解决方法

答案是否定的,Git目前(2.3版)无法通过自动检测二进制和文本格式进行结帐EOL转换,以便仅处理文本.解决方法是仅对选定的文件类型(例如* .txt)指定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 adding eol=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.

猜你在找的HTML相关文章