Skip to main content

.gitattributes

PropertyValue
descriptionStarter Git attributes file for line endings and archive exports.
tagslib, git, github
rating

Overview

Use this as a starter .gitattributes file for Git repositories that need predictable line endings and cleaner release archives.

It does two things:

  • Excludes local/project-maintenance files from git archive exports with export-ignore.
  • Normalizes text files with Git and forces LF endings for common source/config file types.

If needed, run after adding .gitattributes:

git add --renormalize .
git commit -m "Normalize line endings"

Variants

# Export Ignore (exclude from git archive / releases)

/.github export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore

README.md export-ignore
readme.txt export-ignore

node_modules export-ignore
vendor export-ignore

.env export-ignore
.env.local export-ignore

.DS_Store export-ignore
Thumbs.db export-ignore

# Line Ending Normalization

* text=auto

# Force LF for Text Source Files

*.md text eol=lf
*.mdx text eol=lf
*.txt text eol=lf

*.html text eol=lf
*.css text eol=lf
*.scss text eol=lf

*.js text eol=lf
*.jsx text eol=lf
*.ts text eol=lf
*.tsx text eol=lf

*.php text eol=lf

*.json text eol=lf
*.jsonc text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.xml text eol=lf

*.ps1 text eol=lf
*.psm1 text eol=lf
*.psd1 text eol=lf
*.sh text eol=lf