解决方法是将 Git 项目的autocrlf
参数设置为false
,使得 Git 不再自动转换换行符。
在命令行环境下可以通过指令设置
$ git config core.autocrlf false
或者修改.git/config
文件,在core
字段增加autocrlf = false
,如
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
autocrlf = false
[remote "origin"]
url = git@github.com:demo/example.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
此问题的更多解释参考:https://www.jianshu.com/p/450cd21b36a4