我有一个在我的linux机器上正常运行的文件,当我将repo拉到我的windows机器上时,文件完好无损且正确。
然而,当我启动我的流浪服务器,它有一个虚拟驱动器到我的Windows机器,我在浏览器中收到一个javascript错误,如下所示:
Uncaught SyntaxError: Unexpected end of input
当我检查文件时,最后几行消失了,我看到了:
????????????????????????
在文件的末尾。
我已经超越了' autocrlf'来自github(https://help.github.com/articles/dealing-with-line-endings)的说明,它没有效果。
我实际上并不确定发生了什么......但我该如何解决?
答案 0 :(得分:1)
使用规则创建一个.gitattributes文件,该规则在git checkout上将文本文件(自动检测到)从CRLF(\r\n
)转换为LF(\n
)。
* text=auto eol=lf
您需要执行git checkout才能使这些更改生效。
git add . -u
git commit -m "Saving files before refreshing line endings"
git rm --cached -r .
git reset --hard
git add .
# It is perfectly safe to see a lot of messages here that read
# "warning: CRLF will be replaced by LF in file."
git commit -m "Normalize all the line endings"
就是这样 - 你的CRLF EOL字符被转换为LF(并将保持这种方式)。如果您有任何问题,请告诉我们!