Github for windows changing line endings on commit

2020-07-17 15:37发布

问题:

I have a developer that's works with me and randomly his files get changed to CRLF line endings.

In github for windows it shows the correct change before commit, and when committed the line endings get changed and it shows a bad diff.

This only happens randomly, but cant figure out why it is changing.

回答1:

Drop to the command line instead of using Github for windows. MSysGit will follow more closely what is implemented for git by the maintainers of the main git source code.

git config --system core.autocrlf false
git config --system core.whitespace cr-at-eol

Don't let your version control system mess with your line endings unless it absolutely has to.



回答2:

As mentioned in "Android line breaks and git":

  • check if core.autocrlf is set to false (see "Definitive recommendation for git autocrlf settings")
  • check (and this wouldn't have anything to do with GitHub for Windows) if your repo doesn't contain .gitattributes files with eol directives in them which would impose, for a certain file extension, a particular eol style.


回答3:

v1.0.7 takes care of this. Here's a nice article.



标签: git github