博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[git] warning: LF will be replaced by CRLF
阅读量:7023 次
发布时间:2019-06-28

本文共 2062 字,大约阅读时间需要 6 分钟。

  hot3.png

在window7下使用git的时候,建立一个新的库

git init

然后再把文件添加到库中

git add -A

但是出现了问他 提示:

warning: LF will be replaced by CRLF…..

解决办法:

在git bash  输入下面的命令:

git config --global core.autocrlf  false(2个’-')

删掉项目中的.git文件夹 $  rm -rf .git

重新

git init  -》git add -A  问题解决!

下面是在Stack Overflow一位外国朋友的回答,阐述了为什么这样做。

/*add at 2012-03-13  解释为什么要按照上面做*/

Git has two modes of how it treats line endings:

$ git config core.autocrlf # that command will print either "true" or "false"

You can set the mode to use by adding an additional parameter of true or false to the above command line.

If core.autocrlf is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit. Whenever you git checkout something, all text files automatically will have their LF line endings converted to CRLF endings. This allows development of a project across platforms that use different line-ending styles without commits being very noisy because each editor changes the line ending style as the line ending style is always consistently LF.

The side-effect of this convenient conversion, and this is what the warning you’re seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a “for your information” in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.

If core.autocrlf is set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok, as long as all your developers are either on Linux or all on Windows. But in my experience I still tend to get text files with mixed line endings that end up causing problems.

My personal preference is to leave the setting turned ON, as a Windows developer.

转载于:https://my.oschina.net/i33/blog/49705

你可能感兴趣的文章
我心中的核心组件(可插拔的AOP)~第十二回 IoC组件Unity
查看>>
字节顺序:高位优先(big-endian)和低位优先(little-endian)
查看>>
Spring3系列4-多个配置文件的整合
查看>>
SQLServer2005重建索引前后对比【转】
查看>>
Inode详解
查看>>
jquery加入收藏代码
查看>>
7z命令行工具
查看>>
C#获取cpu序列号 硬盘ID 网卡硬地址以及操作注册表 .
查看>>
AutoCompleteTextView 与sqlite绑定实现记住用户输入的内容并自动提示
查看>>
WPF弹性模拟动画
查看>>
[ACM_水题] ZOJ 3714 [Java Beans 环中连续m个数最大值]
查看>>
Java Collection
查看>>
Java Android HTTP实现总结
查看>>
Makefile 中会在多处地方看到 FORCE
查看>>
hadoop参数传递
查看>>
揭秘uc浏览器四
查看>>
SharePoint 2013 Step by Step——How to Create a Lookup Column to Another Site(Cross Site)
查看>>
用条件注释判断浏览器版本,解决兼容问题
查看>>
[经验帖]外包如何定价
查看>>
Unity依赖注入使用详解
查看>>