What is a .gitattributes file?
text/plain
A .gitattributes file assigns per-path attributes that change how Git handles matching files. It controls end-of-line normalisation (`text`, `-text`, `eol=lf`), diff and merge drivers, export filtering, `linguist-*` language hints, and Git LFS filters, using the same pattern syntax as .gitignore with attributes listed after each pattern.
How to use a .gitattributes file
Use an example .gitattributes file to test attribute parsers and repository-tooling that has to honour line-ending or diff-driver rules, verifying that binary paths are excluded from text normalisation and that later patterns override earlier ones.
Download example .gitattributes files
- Gitattributes - End-of-Line Normalisation RulesThe attribute file that decides what happens to line endings on checkout: `text=auto` as the default, explicit `eol=lf` and `eol=crlf` overrides, the `binary` macro that expands to `-text -diff`, and one `-text` entry that is still given a textconv driver. This is the file whose absence causes the CRLF twins elsewhere in this category.
- Gitattributes - LFS Filters, Linguist Hints and export-ignoreThe non-EOL half of the format: LFS filter/diff/merge triples, `linguist-generated` and `linguist-vendored` hints that hide files from language statistics and review, `export-ignore` entries that drop paths from `git archive`, and a `merge=union` driver for an append-only changelog. Attribute values are unquoted and space-separated, so column alignment is whitespace a parser must collapse.