r/git • u/mangodog0net • Oct 30 '26
What is .gitattributes
What is .gitattributes? I'm just a beginner of git, and i just found godot-generated .gitattribute, I also have some of it and it's kinda like literally attributes?
0
Upvotes
10
u/elperroborrachotoo Oct 30 '26
It customizes handling for special files or file types.
The most common use case is telling git what files are binary and what files are text. (Only the latter are affected by platform-specific end-of-line-translation, if tis option is active.)
It's also used by git-lfs ("Large File System", a git add-on to handle large binary files better).
In general, you specify a pattern (or regexp) and various options:
*.psd filter=lfs diff=lfs merge=lfs -textThis allwos to use custom diff tools or merge policies for some files.
5
u/WoodyTheWorker Oct 30 '26
git help attributes
3
u/CartographerDue5382 Oct 30 '26
for the godot one, the line that actually matters is usually
* text=auto eol=lf. that stops windows from checking scripts out as crlf and making the whole file look changed. it's just per-path rules, so you can also put*.png binaryor*.import linguist-generatedif github's language bar gets eaten by import files. if your diffs already look normal you can leave it alone.5
u/_AACO Oct 30 '26
Have you read the official docs or the "easy to read" version of w3 schools?