使用IDEA提交代码时提示You are about to commit CRLF line separators to the Git repository

时间:2024-03-23 21:29:23

背景介绍:
IDE工具为IDEA,之前用windows电脑提交代码,同事使用的也是windows电脑。放假时用家里的Mac修改代码后提交就报下面的错误提示:
使用IDEA提交代码时提示You are about to commit CRLF line separators to the Git repository

原因分析:
简单来说就是不同操作系统的换行符不一样,具体参考下面:
LF -UNIX或macOS使用,换行符 \n
CR -Classic macOS使用,换行符 \r
CRLF -Windows使用,换行符 \r\n

解决方法:
点击idea右下角的LF改为CRLF即可
使用IDEA提交代码时提示You are about to commit CRLF line separators to the Git repository