问题描述
我通过将以下 .gitattributes 推送给 master 来禁用自动 EOL 转换:
# disable automatic eol conversions
* text=false
之后,在Linux上推送了一些文件并从Windows机器上拉取了更改,却发现未更改的文件的行尾已从\n转换为\r\n。
我试过了:
- 删除 repo 并执行 git clone(在 Windows 上)
- 在 Linux 上运行以下命令并再次推送:
git rm --cached -r . git add -A
- 编辑所有文件并推送它们
替换 .gitattributes 是不可能的,因为当 repo 被 GitHub Actions 克隆时,行尾也应该保持不变。
解决方法
通过向 .gitignore 添加以下行,我设法禁用了所有文件的 EOL 转换:
* binary
我仍然不明白为什么 * text=false
不够用,但至少它现在可以工作了。