Search code examples
giteol

git force local repo to lf eol


i want a local git repo to use always lf eol, no matter what comes from the server. But i don't want this behaviour for every repository, just for one. I'm using tortoise git, if this makes it easier.

my .git/config looks like this

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

But there is still crlf applied to the files. I'm not sure if i did something wrong in this config file, or if i need to run a update command that updates the existing files


Solution

  • Update/create under <repo_path>/.git/info/.gitattributes

    "The attributes allow a fine-grained control, how the line endings are converted. Here is an example that will make Git normalize .txt, .vcproj and .sh files, ensure that .vcproj files have CRLF and .sh files have LF in the working directory, and prevent .jpg files from being normalized regardless of their content" gitattributes

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

    Afterwards do : git add --renormalize .