.gitattributes

What is a .gitattributes file?

Per-path git settings — line endings, merge strategies, LFS tracking, and what to exclude from `git archive`.

Safe format
Type Code
By Git Project
MIME text/plain

Drop any file to identify it

No upload. No signup. No sending your file halfway across the internet.
We tell you what it is, right here in your browser.

What is it

Where .gitignore decides which files git tracks, .gitattributes decides how it tracks them. Each line is a path pattern followed by attributes: `*.png binary` tells git not to try diffing PNG files. `* text=auto eol=lf` normalises line endings across Mac/Linux/Windows checkouts. `*.psd filter=lfs diff=lfs merge=lfs -text` hands a file off to Git LFS. The file lives at the repo root and is committed alongside the code it describes.

The most common use is line-ending control. Without .gitattributes, Windows users commit CRLF, Mac/Linux users commit LF, and your diffs become unreadable churn. Setting `* text=auto eol=lf` tells git to convert line endings on checkin and store them as LF in the repo — every contributor sees the same thing. The second most common use is `export-ignore`: marking files (tests, CI config, docs) that should be excluded from `git archive` tarballs, so your release zip doesn't include `.github/` or `node_modules/`.

More advanced uses: custom merge drivers (`merge=ours` to always take your version), custom diff drivers (so Word docs diff as text), and language detection overrides for GitHub's Linguist (`*.h linguist-language=C` instead of C++). Most projects only need a few lines. Like .gitignore, edit it with any text editor, commit it to the repo, and it applies to everyone who clones.

Technical details
Full Name
.gitattributes
MIME Type
text/plain
Developer
Git Project
Magic Bytes
N/A
Safety
.gitattributes is a known, safe format.
What opens it
Any text editor
FREE All
VS Code
FREE All
FAQ
What's the difference between .gitignore and .gitattributes?
.gitignore decides which files git tracks. .gitattributes decides how git treats files it does track — line endings, merge behaviour, whether to use LFS, what to exclude from archives. They solve different problems and most repos benefit from both.
Do I need .gitattributes if everyone on the team uses the same OS?
Probably not strictly, but it's still a good idea. CI runners often run Linux even when developers use Mac/Windows, and contributors from outside the team won't know your conventions. `* text=auto eol=lf` is one line that prevents an entire category of cross-platform line-ending headaches.
Related formats