Vagrant w / windows作为主机,由于crlf文件不能在vm上运行

时间:2014-01-29 18:49:24

标签: python linux windows git vagrant

我正在设置以窗口为主机和ubuntu为guest的流浪者。

我想将流浪汉文件本身发送到repo,所以步骤就是,在windows中克隆repo,流浪汉并准备好运行env。

问题是,由于repo是在windows中克隆的,所有文件都有crlf。当这些是从vagrant ssh执行时,抛出错误

如果一个repo与windows一起作为主机和linux作为来宾共存,那么使用windows的我的队友仍然可以安全地编辑文件并提交它们吗?

提前致谢

2 个答案:

答案 0 :(得分:3)

找到解决方案,

对于git,设置配置如下:git config --global core.autocrlf input

来源:http://blog.xjtian.com/post/54399466362/vagrant-tips-for-windows-users

答案 1 :(得分:3)

我不建议将core.autocrlf设置为除“false”以外的任何内容:

git config --global core.autocrlf false

这是存储库范围的设置,它将应用于所有文件,包括二进制文件。正如我在“Trying to commit Git files but getting: fatal: LF would be replaced by CRLF in <some file in repo>”中解释的那样,它可以破坏那些。

如果对于某种类型的文件,则需要确保其中使用的EOL,在.gitattributes file中声明core.eol指令。

  

要控制工作目录中使用的行结束样式,请对单个文件使用eol属性,对所有文本文件使用core.eol配置变量。

# Declare files that will always have CRLF line endings on checkout.
*.css text eol=lf
*.html text eol=lf
*.js text eol=lf

codewall example提供Scott Grogan (ninjascribble)