I’ve been struggling with this issue for quite some time, tried several tips from here and stack overflow. Finally, I found some sort of workaround, but still there is something that bothers me.
The project in question is a mixed platform (both Windows and Linux). All text files are normalized in the repository (they were all committed with LF). The objective:
- text files in the working folder should always have CRLF on Windows and LF on Linux.
- .gitattributes should always have precedence, regardless of core.autocrlf and core.eol
says: “When you commit this file to a repository, it overrides the core.autocrlf setting for all repository contributors.” The underlined commit is mine.
That’s exactly what I need, so I put the following line in my .gitattributes:
After several experiments, I found that during checkout, core.autocrlf overrides .gitattributes as follows:
- when core.autocrlf = input, files checked out on Windows have LF line terminators.
- when core.autocrf = true, files checked out on Linux have CRLF line terminators.
My current workaround is to make sure that all the machines have both core.autocrlf and core.eol not set, but that’s not convenient when machines are too many (not my case, fortunately).
How do I ignore the machine settings also while checking files out? Not only during commit, as stated above.
Thanks in advance.