Dealing with EOL characters in Cygwin Git and Git for Windows accessing the same repository

不打扰是莪最后的温柔 提交于 2019-12-21 12:37:31

问题


My autocrlf is equal to true. In my cygwin-shell git status gives me a correct list of all my changes.

In Git Bash git status says I modified all files in the project. I also see this in Git GUI and the Changes-tab in IntelliJ.

How is this possible, and more importantly, how can I fix it?


回答1:


Cygwin Git "sees the world" as if it runs on a POSIX platform—thanks to the emulation provided by Cygwin. Contrary to this, Git for Windows is a native Windows program which does not use any emulation and tries to be as close to Windows standards (however idiotic) as possible. What this leads to is that for Cygwin Git, LF is the standard EOL character, while for Git for Windows, the native EOL sequence is CRLF. So both tools see the world differently, and that explains what you observe. Please read this recent thread for more info (and especially this message).

In either case, consider setting core.autocrlf to false anyway to avoid headaches bound to this "magic". I'm using GfW solely, and in the end switched that setting to false (it defaults to true) for good.

You might also find the extremely well commented .gitattributes file from the Mono project to be interesting to study.



来源:https://stackoverflow.com/questions/26407408/dealing-with-eol-characters-in-cygwin-git-and-git-for-windows-accessing-the-same

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!