【问题标题】:git force local repo to lf eolgit 强制本地 repo 到 lf eol
【发布时间】:2020-08-03 11:14:34
【问题描述】:

我希望本地 git repo 始终使用 lf eol,无论来自服务器的什么。 但我不希望每个存储库都有这种行为,只是为了一个。我正在使用乌龟 git,如果这样更容易的话。

我的 .git/config 看起来像这样

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    eol = lf
    autocrlf = false
    safecrlf = false

但是仍然有 crlf 应用于文件。我不确定我是否在这个配置文件中做错了什么,或者我是否需要运行更新现有文件的更新命令

【问题讨论】:

    标签: git eol


    【解决方案1】:

    <repo_path>/.git/info/.gitattributes下更新/创建

    “属性允许细粒度控制,如何转换行尾。这里有一个例子,将使Git标准化.txt.vcproj.sh文件,确保.vcproj文件有@ 987654327@ 和.sh 文件在工作目录中有LF,并防止.jpg 文件被规范化,无论其内容如何“gitattributes

    *           text=auto
    *.txt       text
    *.vcproj    text eol=crlf
    *.sh        text eol=lf
    *.jpg       -text
    

    之后做:git add --renormalize .

    【讨论】:

      猜你喜欢
      • 2012-04-16
      • 1970-01-01
      • 1970-01-01
      • 2011-01-18
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多