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