how to make git not change line endings for one particular file?

Git

Git Problem Overview


due to a "feature" in Microsoft's Visual Studio, .sln files must have windows style line endings so that the windows explorer could open them in Visual studio. So I need to be able to commit this one particular file with line endings intact. It is fine if all other files get converted. The question is how to make git accept just one single file with windows endings?

Git Solutions


Solution 1 - Git

Take a look at the gitatttributes documentation. With recent versions of git, you can set the eol attribute for files to control what end-of-lines will be used when the file is checked out.

You should be able to create a .gitattributes file in your repository that looking something like:

path/to/my/file eol=crlf

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionakonsuView Question on Stackoverflow
Solution 1 - GitlarsksView Answer on Stackoverflow