Gitattributes Generator

Generate a .gitattributes with line-ending, binary and diff rules.

  • Runs locally in your browser
  • No upload required

Try it

File
.gitattributes
Rules
16
Content
# Generated in the browser — review this file and adapt it to your project before committing. * text=auto eol=lf *.sh text eol=lf *.bat text eol=crlf *.cmd text eol=crlf *.ps1 text eol=crlf *.png binary *.jpg binary *.pdf binary package-lock.json -diff pnpm-lock.yaml -diff yarn.lock -diff composer.lock -diff Gemfile.lock -diff dist/** linguist-generated=true *.min.js linguist-generated=true *.min.css linguist-generated=true
# Generated in the browser — review this file and adapt it to your project before committing.

* text=auto eol=lf
*.sh text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.png binary
*.jpg binary
*.pdf binary
package-lock.json -diff
pnpm-lock.yaml -diff
yarn.lock -diff
composer.lock -diff
Gemfile.lock -diff
dist/** linguist-generated=true
*.min.js linguist-generated=true
*.min.css linguist-generated=true

Supported formats

Input
text
Output
text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

Generated a .gitattributes with 18 rule(s).

How it works

  • Normalized text files to lf with `* text=auto eol=lf`.
  • Marked 3 binary extension(s) and 2 LFS extension(s).
  • Marked lockfiles as non-diffable so they do not produce noisy diffs.
  • Apply the file with `git add --renormalize .` after changing the line-ending rule.
  • The file is a starting point: review it before committing.

Methodology

  1. Emit the requested text-normalization rule (`* text=auto eol=<lf|crlf>`).
  2. Expand each binary and LFS extension into a `*.<ext>` rule.
  3. Add lockfile, linguist-generated and platform line-ending rules, then de-duplicate in emit order.

Usage

  1. Choose the line-ending normalization and whether lockfiles are binary.
  2. List any binary or Git LFS extensions.
  3. Run the generator and copy or download the .gitattributes.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

LF normalization with images and LFS

jsonSelect to copy
{
  "normalize": true,
  "eol": "lf",
  "binaryExtensions": "png, jpg, pdf",
  "lockfiles": "binary",
  "linguistGenerated": true,
  "lfsExtensions": "psd, zip"
}

Minimal attributes

jsonSelect to copy
{
  "normalize": true,
  "eol": "crlf",
  "binaryExtensions": "",
  "lockfiles": "text",
  "linguistGenerated": false,
  "lfsExtensions": ""
}

Limitations

Why line endings need an explicit rule

Windows and Unix editors disagree about line endings. A `* text=auto eol=lf` rule makes Git store one canonical form in the repository so diffs stay stable across platforms.

Binary and LFS extensions are marked explicitly because Git cannot always detect them, and a misdetected image corrupts on checkout when it is normalized as text.

Frequently asked questions

Will this convert my existing files?
No. A .gitattributes controls how Git treats files from now on; existing tracked content is only renormalized when you run `git add --renormalize .`.
Why mark lockfiles as binary?
Lockfiles change wholesale and are hard to review line by line. Marking them `-diff` keeps them out of diffs; leave them as text if you prefer readable diffs.

Sources

  1. gitattributes(5) — Git documentation — Git project
  2. git-lfs — Git Large File Storage — Git LFS