What Is .gitattributes and What Is It For?
A .gitattributes file lets you define path-specific attributes that control how Git handles certain files, most commonly line-ending normalization.
Published September 29, 2026
A .gitattributes file lets you define path-specific attributes that control how Git handles certain files, most commonly line-ending normalization.
Key points
- Commonly used to force consistent line endings across operating systems, e.g. "*.sh text eol=lf"
- Can mark specific file types as binary so Git never tries to diff or merge them as text
- Also used to control which files are included when generating an archive, or how diffs are displayed for special formats
Example
*.sh text eol=lf
*.png binary