Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 423
Akkuma Avatar asked Jul 12 '11 19:07

Akkuma


People also ask

Does Gitattributes override Autocrlf?

gitattributes not override core.

Where do I put the Gitattributes file?

gitattributes file in one of your directories (normally the root of your project) or in the . git/info/attributes file if you don't want the attributes file committed with your project.

What is a .gitattributes file?

DESCRIPTION. A gitattributes file is a simple text file that gives attributes to pathnames. Each line in gitattributes file is of form: pattern attr1 attr2 ... That is, a pattern followed by an attributes list, separated by whitespaces.


1 Answers

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
like image 87
Ben Avatar answered Sep 21 '22 12:09

Ben