git 强制本地回购到 lf eol

git force local repo to lf eol

我希望本地 git 存储库始终使用 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。我不确定我是否在这个配置文件中做错了什么,或者我是否需要运行更新现有文件的更新命令

Update/create 在 <repo_path>/.git/info/.gitattributes

"属性允许 fine-grained 控制行尾的转换方式。这是一个示例,可以使 Git 规范化 .txt.vcproj.sh个文件,确保.vcproj个文件在工作目录下有CRLF个,.sh个文件有LF个,防止.jpg个文件无论如何都被规范化他们的内容” gitattributes

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

之后做:git add --renormalize .