美文网首页
git diff时^M的处理

git diff时^M的处理

作者: Eazow | 来源:发表于2023-06-19 14:52 被阅读0次

问题

将git从库从windows拷贝到linux/macOS时,很多变动,diff时会显示^M

问题原因

因为windows用的CRLF当作换行符,linux用的LF,所以有区别

解决方法

git diff的时候忽略换行符的差异

git config --global core.autocrlf input

也可以修改.gitattributes

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

相关文章

网友评论

      本文标题:git diff时^M的处理

      本文链接:https://www.haomeiwen.com/subject/moseydtx.html