>* text=auto

This option will let Git handle the automagic line endings conversion for you, on commits and checkouts. Binary files won't be altered, files detected as being text files will see the line endings converted on the fly.

Git defines text files excellent. To set file extensions which must be stored with LF line endings in repo its possible to add additional strings:

    *.php  text
    *.png  binary

I got unique extensions for yii2 (osx):

    find . -type f | sed -E 's/.+[\./]([^/\.]+)/\1/' | sort -u

It's possible to use such . gitattributes config:

    # Autodetect text files
    * text=auto

    # ...Unless the name matches the following
    # overriding patterns

    # Definitively text files 
    *.php  text
    *.css  text
    *.js   text
    *.txt  text
    *.md   text
    *.xml  text
    *.json text
    *.bat  text
    *.sql  text
    *.xml  text
    *.yml  text

    # Ensure those won't be messed up with
    *.png binary
    *.jpg binary
    *.gif binary
    *.ttf bin