What will `* text=auto eol=lf` in gitattributes do?

情到浓时终转凉″ 提交于 2019-11-27 08:01:32

Git 2.10 fixed this and now behaves as one would expect.

Borek Bernard

The answer is no, Git currently (as of 2.3) cannot do checkout EOL conversion with auto-detection of binary and text formats so that it processes text only. The workaround is either to specify eol=lf only for selected file types (e.g., *.txt) or, inversely, mark certain file types as binary using e.g. *.png binary).

Related: 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!