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

gitattributes中的`* text = auto eol = lf`会做什么?,第1张

概述我们在.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 reposi 我们在.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.

总结

以上是内存溢出为你收集整理的gitattributes中的`* text = auto eol = lf`会做什么?全部内容,希望文章能够帮你解决gitattributes中的`* text = auto eol = lf`会做什么?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1099866.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存