.gitattributes

Run this git command:

git config filter.\"fix\".clean \"expand -t2 -i %f\";

If you have the following in each .git/config file
 

[filter "fix"]
    clean = expand -t2 -i %f

 

then you can use "fix" as a filter in the related .git/info/attributes file as in the following

*.bmp binary
*.css text eol=lf filter=fix
*.scss text eol=lf filter=fix
*.gif binary
*.html text eol=lf filter=fix
*.jpeg binary
*.jpg binary
*.js text eol=lf filter=fix
*.json text eol=lf filter=fix
*.module text eol=lf filter=fix
*.php text eol=lf filter=fix
*.inc text eol=lf filter=fix
*.theme text eol=lf filter=fix
*.pdf binary
*.png binary
*.yml text eol=lf filter=fix

binary forces the file type to not be converted

text eol=lf forces lf endings

filter=fix uses the fix filter in the config file which is needed due to attributes not supporting spaces in commands or quotations

I don't understand why, but the expand program in git works on windows despite windows already having a program called expand that uncompresses zip files. Even on a clean win10 install from a dos cmd prompt, git still uses the linux expand program instead of the windows one. So should be consistent for everyone.

The files won't be updated automatically in each users computer. The files will be updated in the git repo. If you want the cleaned files on your computer then you need to "rm -rf ." and "git checkout ." to get the cleaned files from the repo.

 

Comments

git config filter.trimspace.clean 'sed -e "s/[[:space:]]*$//g"'
git config filter.trimspace.smudge cat 
.gitattributes
*.js filter=trimspace
*.css filter=trimspace

 

ensuite:

git add --renormalize js/*