Git .gitattributes

Configure how Git handles line endings, binary files, and merge strategies using .gitattributes.

On this page

What is .gitattributes?

.gitattributes defines attributes for paths in your repository.

Control line endings

* text=auto
*.js text
*.png binary

Custom merge strategy

*.lock merge=ours

When to use

  • Cross-platform development
  • Prevent line ending conflicts
  • Handle binary files properly