文件无改动但 IDEA 仍然显示有改动

IDEA Git About 476 words

现象

git diff无差异但IDEA仍然显示有改动。

git rollback后能让IDEA显示无改动。

备注

尤其是前端项目。

原因

文件换行符的差别。

WindowsCRLF

Linux/UnixLF

Classic Mac OSCR

IDEA

IDEA中会在Show Diff弹窗中显示:Contents have differences only in line separtors

同时也会显示远程的换行符和本地的换行符。

换行符.png

git config -l

使用如下命令可查看git是否自动转换换行符。

git config -l

输出:autocrlf自动转换为Windows格式。

PS C:> git config -l
...
core.autocrlf=true
...

解决方法

IDEA底部直接切换对应平台换行符即可。

底部栏 line separtator.png

视频讲解

https://www.bilibili.com/video/BV1XG4114749

https://www.ixigua.com/i7134703125318861347

Views: 3,007 · Posted: 2022-08-22

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh