【发布时间】:2013-03-19 00:43:33
【问题描述】:
这是我的系统对话:
unrollme-dev-dan:views Dan$ git reset --hard HEAD
HEAD is now at 3f225e9 Fix scan titles
unrollme-dev-dan:views Dan$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/signup/finish.html
# modified: app/signup/scan.html
#
我已将 autocrlf 设置为 false:
unrollme-dev-dan:unroll-website Dan$ git config core.autocrlf
unrollme-dev-dan:unroll-website Dan$
unrollme-dev-dan:unroll-website Dan$ git config --global core.autocrlf
unrollme-dev-dan:unroll-website Dan$
而且我没有任何 .gitattributes 文件搞砸了:
unrollme-dev-dan:unroll-website Dan$ find . -name .gitattributes
[ only results are in different directory tree ]
这是由.gitattributes 引起的,如下面的答案中所指出的那样。
当我对文件执行od -c 时,它会显示\r\n。我不知道它们“应该”是什么,大概它们应该以\n 结尾,这就是显示差异的原因。但我不明白的是,即使使用autocrlf false,这些文件也可能在结帐时被修改。
除了 autocrlf 之外,还有什么会导致 git 在结帐时修改文件?
【问题讨论】:
-
可能是 this question 的副本,在其中一个得到对两者都适用的正确答案之前,不要投票结束。
-
什么操作系统顺便说一句?我假设是 Windows?
-
@Ikke Mac/Unix。看来我家的 Mac 还是丢掉了额外的 CR,我可能把 nano 配置错了。
-
同时检查
core.safecrlf。理论上,由于core.eol和core.autocrlf都关闭了,这应该不会有任何影响,但我还没有真正玩过这三个变量的所有可能组合...
标签: git newline core.autocrlf