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

I am trying to install specific files to always use lf, not crlf, regardless of autocrlf on the local system.

I tried creating .gitattributes in the project root containing only SquishIt.Tests/js/*.js eol=lf , and I also tried SquishIt.Tests/js/ eol=lf . I pressed both of these attempts on my remote, and then tried to clone it locally twice. Files in / js / always showed with CR + LF in both cases, since autocrlf is global to me.

I'm on a Windows computer, just in case this was unclear. Am I trying to achieve what I am trying to achieve?

+7
source share
2 answers

I wanted all text files to be forced to use LF, except for one auxiliary directory (.idea), which forcibly uses CRLF. Here's what my .gitattributes look like:

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

So, I assume yours should look like this:

 * text=auto /SquishIt.Tests/js/* text eol=lf 
+10
source

I would set autocrlf to false and set core.whitespace to cr-at-eol. It’s better to let your editors understand the differences in line endings. Let git keep them as they are.

Hope this helps.

0
source

All Articles