【发布时间】:2016-02-10 21:08:21
【问题描述】:
所以我决定将我们的 git repo 中所有具有 windows 风格行尾的文件转换为具有 unix 风格的行尾。
我按照http://www.git-scm.com/docs/gitattributes#_end_of_line_conversion的指示:
echo "* text=auto" >>.gitattributes
rm .git/index # Remove the index to force Git to
git reset # re-scan the working directory
git status # Show files that will be normalized
git add -u
git add .gitattributes
git commit -m "Introduce end-of-line normalization"
我后来意识到这也改变了应该保持 CRLF 的 *.bat 文件。我使用以下.gitattributes 文件再次尝试了整个过程:
# Default
* text=auto eol=lf
# Windows-only files
*.bat text eol=crlf
这似乎并没有改变git status 的输出,批处理文件仍然被标记为“已更改”,即使它们在我的工作副本中是 CRLF 并且.gitattributes 将它们设置为完全一样。看起来 git 会简单地忽略带有*.bat 的行。 git show --raw 还向我展示了该文件现在使用 LF 而不是 CRLF 存储。
【问题讨论】:
标签: git