Question

I have a .gitattributes file in my repository that looks like this

* text=auto
*.txt text

I have unset core.autocrlf in the repository, global, and system settings. My understanding, based on the documentation for gitattributes, is that all files in the repository whose names end with .txt should be checked out with the native line endings. What I'm seeing, though, is that the .txt files always have LF for line endings, even on Windows. Given this configuration, why aren't the line endings CRLF on Windows?

Was it helpful?

Solution

The problem is that there is a bug in the handling of core.eol. Documentation for gitattributes says that if it is unset then native will be used, which should default to the proper line endings for your system (CRLF for Windows, LF for unix), however leaving core.eol unset or setting it to native on my system always results in LF for line endings. The answer, then, is to set core.eol to crlf on Windows explicitly. The comments at http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/ led me to this answer.

OTHER TIPS

you need to set core.autocrlf to input. On windows set it to true.

If you are not sharing x-platform, then set it to false and forget about the attributes altogether.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top