在Cygwin Git和Windows的Git中处理EOL字符以访问相同的存储库 [英] Dealing with EOL characters in Cygwin Git and Git for Windows accessing the same repository

查看:88
本文介绍了在Cygwin Git和Windows的Git中处理EOL字符以访问相同的存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 autocrlf 等于true.在我的cygwin-shell中,git status为我提供了所有更改的正确列表.

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

在Git Bash中,git status说我修改了项目中的所有文件.我还在Git GUI和IntelliJ的Changes-tab中看到了这一点.

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?

推荐答案

Cygwin Git可以看到世界",就像它在POSIX平台上运行一样-感谢Cygwin提供的仿真.与此相反,Git for Windows是一个 native Windows程序,它不使用任何仿真,并试图尽可能地接近Windows标准(无论如何).这导致对于Cygwin Git,LF是标准EOL字符,而对于Windows的Git,本机EOL序列为CRLF.因此,这两种工具对世界的看法不同,这可以解释您所观察到的情况.请阅读最新主题以了解更多信息(尤其是此消息).

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).

无论哪种情况,无论如何都要考虑将core.autocrlf设置为false 以避免这种魔术"带来的麻烦.我只使用GfW,最后将设置永久更改为false(默认为true).

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.

您还可能会在Mono项目中找到评论非常完整的 .gitattributes文件使学习有趣.

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

这篇关于在Cygwin Git和Windows的Git中处理EOL字符以访问相同的存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆