【问题标题】:How to set line-endings in git for local copy如何在 git 中为本地副本设置行尾
【发布时间】:2020-03-23 21:23:56
【问题描述】:

我正在开展一个项目,我们在该项目中提取 repos,然后检查各种法律问题。我无法修改外部项目,但可以完全控制我的本地机器(Ubuntu)。我遇到了行尾问题,想知道是否有一种方法可以强制本地副本对所有文件(特定于 Windows 的文件除外)遵守 LF,到目前为止,我们不打算推送更改,只​​是扫描存储库。

【问题讨论】:

    标签: git core.autocrlf


    【解决方案1】:

    要让 Git 猜测最适合您的方式(即 Linux 上的 LF 表示行尾),请执行以下操作

    $ git config --global core.autocrlf input
    # Configure Git to ensure line endings in files you checkout are correct for Linux
    

    在“每个存储库”的基础上,您可以在 repos .gitattributes 文件中设置它,但据我了解,您不想更改 repos。更详细的描述见https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings

    【讨论】:

      猜你喜欢
      • 2021-03-05
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 2017-01-23
      • 1970-01-01
      • 2016-06-03
      • 2014-11-01
      • 1970-01-01
      相关资源
      最近更新 更多