微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

原文地址:https://www.jb51.cc/html/230624.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐