How do I set all files in a subdirectory to use a specific eol using gitattributes?

邮差的信 提交于 2019-12-06 18:16:30

问题


I've been trying to set specific files to always use lf and not crlf regardless of autocrlf on the local system.

I tried creating a .gitattributes at the root of the project that only contained SquishIt.Tests/js/*.js eol=lf and I also tried SquishIt.Tests/js/ eol=lf. I pushed both of these attempts to my remote and then tried cloning it locally twice. The files under /js/ always showed up with CR+LF in both cases as autocrlf is on globally for me.

I'm on a Windows machine, just in case it was unclear. Is what I'm attempting to achieve even possible?


回答1:


I wanted to have all text files forced to use LF except one sub directory (.idea) which is forced to use 'CRLF'. This is how my .gitattributes looks:

* text eol=lf
/.idea/* text eol=crlf

So I assume yours should look like:

* text=auto
/SquishIt.Tests/js/* text eol=lf



回答2:


I would set autocrlf to false and set core.whitespace to cr-at-eol. It's better to let your editors deal with the difference in line endings. Let git store them as they are.

Hope this helps.



来源:https://stackoverflow.com/questions/6670140/how-do-i-set-all-files-in-a-subdirectory-to-use-a-specific-eol-using-gitattribut

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