【Git】warning: LF will be replaced by CRLF in .gitignore解决方案

简介: warning: LF will be replaced by CRLF in .gitignore解决方案

问题

在git add时,出现如下警告

$ git add .
warning: LF will be replaced by CRLF in .gitignore.

解决方法一

1.设置git,将core.autocrlf设置为false

$ git config --global core.autocrlf false

2.设置windows也用LF换行。
git config --global core.autocrlf false
设置一个.editorconfig 来保证文件都是 LF 结尾。
除了记事本,其他编辑器都可以正常编辑

解决方法二

设置 core.autocrlf=true。
然后使用 dos2unix 之类的工具将本地 LF 结尾的文件改为 CRLF 结尾;

原理

参考Git 多平台换行符问题(LF or CRLF)

相关文章
|
人工智能 运维 Linux
一文了解IntelliJ IDEA如何使用git上传代码到GitHub(附常见问题解决方案)
一文了解IntelliJ IDEA如何使用git上传代码到GitHub(附常见问题解决方案)
677 0
|
19天前
|
安全 开发工具 git
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
138 5
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
|
19天前
|
Shell Linux 网络安全
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
154 3
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
|
缓存 Shell 开发工具
git 基本 使用和.gitignore文件不生效
git 基本 使用和.gitignore文件不生效
244 0
|
3月前
|
算法 安全 网络安全
git clone操作报错diffie-hellman-group1-sha1的解决方案
在处理这一问题时,需要确保了解相关操作的安全影响。`diffie-hellman-group1-sha1`算法被认为是不够安全的,这是因为随着计算能力的提高,`SHA-1`算法可以在合理的时间内被破解,而且其对应的 `1024位`Diffie-Hellman组也可能不够强大。因此,在确保Git操作的同时,也要考虑提升安全性的长期解决办法。强烈推荐与管理员或相关技术支持团队合作,升级和加强服务器端的安全配置。
113 12
|
3月前
|
API 开发工具 git
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
182 0
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
|
7月前
|
开发工具 git 索引
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
110 21
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
|
缓存 开发工具 git
给Git仓库添加.gitignore:清理、删除、排除被Git误添加的临时文件
本文介绍了如何为Git仓库添加`.gitignore`文件来排除不需要跟踪的临时文件,并展示了如何删除已经被提交的临时文件缓存,以清理Git仓库中的不必要文件。
1590 0
给Git仓库添加.gitignore:清理、删除、排除被Git误添加的临时文件
|
缓存 开发工具 git
git过滤不需要的修改提交内容.gitignore的使用
git过滤不需要的修改提交内容.gitignore的使用
151 1
|
网络安全 开发工具 git
使用git克隆仓库报错:Warning: Permanently added‘github.com’ to the .....(ssh )
所以,你可以安全地忽略这个警告,它不会影响到你使用git克隆仓库。如果你已经成功克隆了仓库,那么一切都在正常工作。如果你在克隆过程中遇到其他问题,那可能需要查看具体的错误信息来解决。
665 0