git diff时^M的处理

问题

将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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容