【问题标题】:Git push corrupting my export with '\r' charactersGit push 用 '\r' 字符破坏了我的导出
【发布时间】:2013-08-17 19:43:05
【问题描述】:

每当我通过 git 推送时,我的所有 bash 脚本似乎都被 \r 字符损坏了。它不会影响代码,但只会给我的工作增加大量噪音。查遍了整个网络,但似乎找不到解决方案。

例子:

    echo "*************************************************************************"\r

                                                                                     ^

我的 bash 脚本中的每一行总是以这个特殊字符结尾。我在 Windows 7 上使用 STS。有什么想法吗?

【问题讨论】:

  • 您可以尝试在 Eclipse 中从 Windows 换行符切换到 Unix 样式。操作方法如下:stackoverflow.com/questions/1886185/…
  • 刚刚试了,没有任何乐趣。
  • 什么时候添加?你什么时候提交?
  • 您的.gitattributes 文件中是否存在会导致更改行尾的内容?这是一个文档:help.github.com/articles/dealing-with-line-endings
  • 有一个名为 dos2unix 的 unix 工具可以改变 \r,不过,我会检查一下 git 配置使用哪个字母表,也许它正在使用 cp1251,您可以将属性更改为更多兼容...

标签: eclipse git bash maven


【解决方案1】:

如果您需要将此设置设为全局,请将这两行放入您的 repo 根目录中的 .gitconfig 文件或您的主页中:

[core]
   eol = lf

您可以在此处找到更多相关信息:https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-02
    • 2017-01-03
    • 1970-01-01
    • 2013-05-16
    • 2022-08-18
    • 2018-06-06
    • 2012-03-28
    • 1970-01-01
    相关资源
    最近更新 更多