Open JeReT opened 2 years ago
git config core.autocrlf
https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
Git ... auto-converts CRLF line endings into LF when you add a file to the index, and vice versa when it checks out code onto your filesystem. You can turn on this functionality with the core.autocrlf setting. If you’re on a Windows machine, set it to true — this converts LF endings into CRLF when you check out code:
So, if you need, you can disable autocrlf globally (git config --global
), per repository(git config --local
) or per folder/file (.gitattributes
).
Thanks for the reply but I don't think this helps. I have some auto-generated files in my project which always seem to have the wrong line ending. It clutters my changes view. What can I do about it?
I have some auto-generated files in my project which always seem to have the wrong line ending.
I assume you mean the auto-generated files have the unix (LF) line endings, but the rest of the repository is in windows format (CRLF).
Then you should tell git that those files have unix line endings by adding to the.gitattriebutes
file the following:
path/to/autogenerated/files/*.txt eol=lf
Funny, I actually did this in the past. I have to investigate the files I talk about a bit, because sometimes the changes appear and sometimes not. But probably your suggestion will fix it.
Would be nice if I could do this inside fork: If a file doesn't have a diff, fork could show an info: "Line endings detected as [eol-style]" and a button: "Configure line endings". When you press the button, a dialog appears where you can specify the eol style (the one from the file by default) as well as the path (path to the file by default). When confirming, the .gitattributes are modified.
When there is a file which only changed the line endings, fork will show that this file contains changes. When you then stage the file, the file simply disappears. Not sure if this has to do with my git settings.
Steps to reproduce:
Result: the file disappears.
Expected Result: one of these:
(I prefer version 1, but it should probably be different depending on the whitespace settings of the git config. But I'm no git config expert...)