我试图让 git 不改变任何行结束任何操作。不幸的是,似乎这样做并不重要。我已经将它简化为下面的测试用例,其中有尽可能多的禁用此行为的不同机制。
git config --global core.autocrlf false
git config --global core.eol crlf
(以防万一)git init --shared
(然后取消隐藏创建的 .git
目录).gitignore
.gitattributes
,其中只有一行: * -text
git commit -m "initial commit"
,例如 这个。git branch master_recv
document.txt
git add -A
,然后 git commit -m "<something>"
document.txt
仍然包含 CRLF (并且删除它并使用 --hard
重置返回仍然使用 CRLF 的版本)new file
git add -A
,然后 git commit -m "<something>"
document.txt
和 B 的 new file
都仍然包含 CRLFgit pull <remote> master:master_recv
document.txt
已更改为 LF。添加的文件 new file
也包含 LF。如果 B 是 Windows 计算机,则不会出现此问题。