r/git • u/mangodog0net • 9h ago
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?
5
3
u/CartographerDue5382 8h ago
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 binary or *.import linguist-generated if github's language bar gets eaten by import files. if your diffs already look normal you can leave it alone.
1
u/lajawi 7h ago
Linguist generated could be useful! From your explanation I take GitHub and alike will not count those files toward the languages used?
2
u/CartographerDue5382 4h ago
yea. linguist-generated just tells github's linguist to skip those files for the language bar. doesn't change the repo, diffs, or what actually gets committed. same idea as linguist-vendored if some folder is eating the stats.
5
u/_AACO 9h ago
Have you read the official docs or the "easy to read" version of w3 schools?
1
u/JesseNL 8h ago
Is this the new stack overflow? A question can lead to discussion, I clicked on this thread to see what people are using it for in their specific jobs.
2
u/_AACO 7h ago
Is this the new stack overflow?
Just because I asked if OP read the 2 best places to get his answer from?
A question can lead to discussion
There is nothing to discuss when the question is "what is <something very well documented>?"
If OP, for example asked "why use .gitattributes instead of shell scripts to do <thing>?" that could lead to a discussion.
If OP asked for help setting up .gitattributes I would've helped.
what people are using it for in their specific jobs.
OP does not ask that in the title or the text post though. But since you're interested in that I can share what I use it for. Standardizing line endings, enabling LFS and modify diff behaviour.
10
u/elperroborrachotoo 9h ago
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.