.gitattributes with core.autocrlf unset

北战南征 提交于 2019-12-04 13:06:49

问题


I have a .gitattributes file in my repository that looks like this

* text=auto
*.txt text

I have unset core.autocrlf in the repository, global, and system settings. My understanding, based on the documentation for gitattributes, is that all files in the repository whose names end with .txt should be checked out with the native line endings. What I'm seeing, though, is that the .txt files always have LF for line endings, even on Windows. Given this configuration, why aren't the line endings CRLF on Windows?


回答1:


The problem is that there is a bug in the handling of core.eol. Documentation for gitattributes says that if it is unset then native will be used, which should default to the proper line endings for your system (CRLF for Windows, LF for unix), however leaving core.eol unset or setting it to native on my system always results in LF for line endings. The answer, then, is to set core.eol to crlf on Windows explicitly. The comments at http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/ led me to this answer.




回答2:


you need to set core.autocrlf to input. On windows set it to true.

If you are not sharing x-platform, then set it to false and forget about the attributes altogether.



来源:https://stackoverflow.com/questions/13711190/gitattributes-with-core-autocrlf-unset

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