gitattribute end of line setting

5k views Asked by At

I'm working on a code repository where all developers collaborating with the repository using windows PC & eclipse as their IDE. The repository administrator has setup this .gitattributes file in the parent directory with the following:

* text eol=crlf

I read here that git internally maintains object database to write(commit)/read(checkout) the changes.

Does this above setting in .gitattributes will checkout the code with CRLF(windows) line ending and the file in the repository will be maintained in CRLF?

Enabled the "Show White Spaces" option in Eclipse IDE revealed that all the file endings were line feed(LF) without carriage return(CR).

Could someone point out the cause of this behavior?

On a different repository, It has

* text eol=lf
*.java eol=crlf
*.csv eol=crlf
*.jar binary
*.sql eol=crlf

Does this mean all files(.java/.csv/.sql) would have CRLF and other files would have LF line endings?

1

There are 1 answers

1
soundslikeodd On BEST ANSWER

A good source for .gitattributes info are the gitscm.com docs (https://git-scm.com/docs/gitattributes#__code_text_code)

  1. I do not believe * text eol=crlf will work. It should be * text crlf

  2. You need to break the single line * text eol=lf*.java eol=crlf*.csv eol=crlf*.jar binary*.sql eol=crlf into the multiple lines.

Add these lines to your . gitattributes file.

# other files will have LF
* text=lf

# .java .csv .jar .sql will have CRLF
*.java eol=lf 
*.csv eol=crlf
*.jar eol=crlf
*.sql eol=crlf