Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitattribute file not working as expected

I have the following .gitattributes file in my project

*.txt -diff

This works as expected, it ignores .txt files when I do a git diff. However when I change this to

*.txt diff=test

and add

[diff "test"]
    colorMoved = plain

to my .git/config file, it does not work. The colors of git diff do not change.

If I add

[diff]
    colorMoved = plain

It does changes the color in git diff. So my conclusion is that the .gitattributes file is being used and the .git/config is working as well. However the combination does not work. Any ideas what I am doing wrong?

I am using git version 2.33.0.windows.2

like image 452
Frank Avatar asked Oct 24 '25 03:10

Frank


1 Answers

Setting the diff algorithm works for attributes but not for colors or anything else.

git help config shows that the config key is diff.colorMoved but there is no diff.<name>.colorMoved.

Ability to set the diff algorithm per attribute was added somewhere between Git 2.36 and 2.42. Compare the docs for 2.36 and 2.42.

like image 195
phd Avatar answered Oct 25 '25 16:10

phd