目录

LF will be replaced by CRLF

misaraty 更新 | 2026-08-11
前言
Git warning: LF will be replaced by CRLF问题分析与解决方法。

问题

在执行:

1
2
3
git add .
git commit -m "update"
git push

时,终端出现:

1
2
3
warning: in the working copy of 
'xxx.scss',
LF will be replaced by CRLF the next time Git touches it

原因

什么是LF和CRLF?

不同操作系统使用不同的换行符。

系统 换行符
Linux LF
macOS LF
Windows CRLF

为什么Git会提示转换?

Git 为了保证不同操作系统之间协作,会自动处理换行符。

解决方案

关闭Git自动转换

1
git config --global core.autocrlf false

重新规范化

1
2
git rm --cached -r .
git reset --hard

Hugo项目忽略生成目录:

1
2
resources/_gen/
public/