【问题标题】:Vagrant w/ windows as host, files don´t run on vm due to crlfVagrant w/windows 作为主机,由于 crlf,文件不能在 vm 上运行
【发布时间】:2014-01-29 18:49:24
【问题描述】:

我正在尝试设置 vagrant,将 windows 作为主机,ubuntu 作为访客。

我想将 vagrant 文件本身提交到 repo,因此步骤是,在 windows 中克隆 repo,vagrant up 并准备好并运行 env。

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

一个repo如何在vagrant中以windows为host,linux为guest共存,让我使用windows的队友仍然可以安全地编辑文件并提交它们?

提前致谢

【问题讨论】:

  • 配置 git 和你的编辑器以使用 LF。

标签: python linux windows git vagrant


【解决方案1】:

我不建议将 core.autocrlf 设置为“false”以外的任何其他值:

git config --global core.autocrlf false

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

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

要控制工作目录中使用的行尾样式,请对单个文件使用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 exampleScott Grogan (ninjascribble)

【讨论】:

    【解决方案2】:

    找到解决办法,

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-14
      • 2020-09-28
      • 2013-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多