Git 用 CRLF 替换了我所有的 LF - 我该如何解决这个问题?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1474686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:51:33  来源:igfitidea点击:

Git replaced all of my LF with CRLF - How do I fix this?

rubygitrubygemsnewline

提问by S. Michaels

I just ran a

我刚跑了一个

git add -A

on my first git project.

在我的第一个 git 项目中。

I got back about a thousand responses:

我得到了大约一千个回复:

"warning: LF will be replaced by CRLF"

“警告:LF 将被 CRLF 取代”

as it went through each file (Ruby files, some are gems).

当它遍历每个文件时(Ruby 文件,有些是 gem)。

I deleted my .git directory and tried to disable this default setting by typing this command:

我删除了我的 .git 目录并尝试通过键入以下命令来禁用此默认设置:

git config core.autocrlf false

Then I tried to add the files again:

然后我尝试再次添加文件:

git add -A

But I got the same result. Help!

但我得到了同样的结果。帮助!

回答by kolrie

You likely have the core.autocrlfattribute set to true

您可能将该core.autocrlf属性设置为 true

It's a configuration attribute you can set:

这是您可以设置的配置属性:

http://git-scm.com/docs/gitattributes#_checking_out_and_checking_in

http://git-scm.com/docs/gitattributes#_checking_out_and_checking_in

To make sure that is set to false for all Git projects you can do:

要确保所有 Git 项目都将其设置为 false,您可以执行以下操作:

git config --global core.autocrlf false

Hope this helps!

希望这可以帮助!