简体   繁体   English

如何获取git来停止更改文件中的换行符?

[英]How do I get git to stop changing newlines in my files?

I'm using git/github with Eclipse/EGit on Windows. 我在Windows上将git / github与Eclipse / EGit结合使用。 Something -- not sure if it's git or EGit -- is modifying my files by playing games with newlines. 不确定(是否为git或EGit)通过使用换行符玩游戏来修改我的文件。

Leaving aside the mystery of what a version control is doing modifying files by itself, how do I configure this software so it never, ever, changes my files? 抛开版本控制本身进行文件修改的奥秘,如何配置此软件,使其永远不会更改文件?

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

Don't allow it to change anything or report problematic CR bytes at the end. 不允许它更改任何内容或最后报告有问题的CR字节。

You have many options depending on your OS: 您有多种选择,具体取决于您的操作系统:

http://help.github.com/line-endings/ http://help.github.com/line-endings/

The reason for the seemingly bizarre behavior is explained there. 在那里解释了看似奇怪的行为的原因。 Basically the code is being shared (git and github) but the OS may be different. 基本上,代码是共享的(git和github),但操作系统可能有所不同。 As different OS's treat linefeeds differently, something has to change... 由于不同的OS对换行的处理方式不同,因此必须进行一些更改...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM