Following @chepner advice for the .gitattribute file I used him proposed configuration. It didn't work as expected so I did some more digging. Turns out the answer was in the Git manual! (RTFM, I know right?!).
Check the EFFECTS section on Git Manual.
eol
This attribute sets a specific line-ending style to be used in the
working directory. It enables end-of-line normalization without any
content checks, effectively setting the text attribute.
Set to string value "crlf
"
This setting forces Git to normalize line
endings for this file on checkin and convert them to CRLF when the
file is checked out.
Set to string value "lf
"
This setting forces Git to normalize line
endings to LF on checkin and prevents conversion to CRLF when the file
is checked out.
What I actually needed is -text
. By using -text
you ask Git to treat that file as a binary and not affect its line endings.
Unsetting the text
attribute on a path tells Git not to attempt any
end-of-line conversion upon checkin or checkout.
And the backwards compatible version:
Backwards compatibility with crlf
attribute
For backwards compatibility, the crlf
attribute is interpreted as follows:
crlf text
-crlf -text
crlf=input eol=lf