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?
However, it does not modify line endings in your working tree. This is essentially the same as setting core. autocrlf=input in your Git settings. More specifically, the text=auto option tells Git to only normalize line endings to LF for text files while leaving binary files (images, fonts, etc.)
use a text editor like notepad++ that can help you with understanding the line ends. It will show you the line end formats used as either Unix(LF) or Macintosh(CR) or Windows(CR LF) on the task bar of the tool. you can also go to View->Show Symbol->Show End Of Line to display the line ends as LF/ CR LF/CR.
Git store whole files as "blobs" and only do conversion when reading (checking out) or writing (indexing). Git does not store "neutralized lines". So yes, Git can save files with mixed line endings, but that's usually a bad practice to avoid.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With