Search code examples
giteolgitattributes

Force LF eol in git repo on all platforms with .gitattributes


I have a remote repo that is being cloned and worked on in boths windows and mac. I want whenever anyone pulls this repo, it should automatically use LF eol on any platform.

My main issue occurs whenever the Windows Build Server pulls the repo. I don't have control over executing any config commands on the server so I'd like to only use the .gitattributes file for this problem. The reason for LF is that there are some build tools that require the source files to be LF eol.

Is this file saying that all text files will be checkedout with LF eol while skipping jpg and png files? If not, what would this file look like to accomplish the above?

.gitattributes file

* text=auto eol=lf
*.jpg binary
*.png binary

Solution

  • Try just

    text eol=lf
    

    Git will always convert line endings to LF on checkout.

    text=auto will use the git defaults which might not be the same everywhere.