.gitattributes Generator
Generate a .gitattributes file: pick a line-ending normalization strategy, select your languages, frameworks and binary file types from searchable multi-select lists, and add merge-strategy overrides for lock files and changelogs. Merges every choice into one de-duplicated, ready-to-paste file.
Input
Choose how line endings should normalize, select every language, framework and binary file type your project uses from the lists below, then add any merge-strategy overrides. Everything merges into a single de-duplicated file below.
Line Ending Normalization
text=auto normalizes line endings to LF in the repository regardless of what contributors check out. Add eol=lf/eol=crlf to also force a specific checkout line ending.
Custom Rules
Appended under a “Custom Rules” header. Lines starting with # are kept as comments.
Output
Guides
Create a ready-to-use .gitattributes file by picking a line-ending normalization strategy, selecting the languages, frameworks and binary file types your project uses from searchable multi-select lists, and adding merge-strategy overrides for lock files and changelogs. The generator merges every choice into one clean, de-duplicated file.
What is a .gitattributes file?
A .gitattributes file tells Git how to treat specific paths — whether a file is text or binary, which line ending it should normalize to, which diff driver to use, and how conflicting changes should merge. It fixes the classic "every file shows as changed" problem caused by mixed CRLF/LF line endings across Windows, macOS and Linux contributors, and keeps binary assets (images, fonts, archives) out of noisy text diffs.
How to use this generator
- Choose a global line-ending rule —
text=autonormalizes line endings on commit while leaving checkout untouched, or force a specific checkout ending witheol=lf/eol=crlf. - Select every language and framework your project uses from the multi-select list — the output updates instantly.
- Select binary file groups (images, fonts, archives, documents & media) so Git never tries to diff or merge them as text.
- Add merge-strategy overrides (e.g. union merge for
CHANGELOG.md) where two branches' changes should combine rather than conflict. - Paste any project-specific rules into the Custom Rules box, one per line.
- Copy the result or download it directly as
.gitattributesinto the root of your repository.
How the merge works
Each selected preset is written under its own # Name header, and rules are de-duplicated globally: if two presets declare the exact same line, it's kept only once, under the first preset to declare it. That means combining a language, a lock-file rule and a binary group never produces a file full of repeated lines.
Why do lock files get -diff -merge?
Lock files like package-lock.json, yarn.lock and Cargo.lock are generated and can be huge — diffing or attempting a text merge on them is slow and rarely useful. -diff hides them from git diff/git show, and -merge forces a straight conflict instead of a garbled auto-merge, so you always regenerate the lock file after resolving.
Where does the .gitattributes file go?
Place it in the top-level directory of your Git repository, same as .gitignore. Rules apply to that folder and all subfolders; add nested .gitattributes files for directory-specific overrides.
Do existing files need to be re-normalized?
Adding a line-ending rule only affects files as Git re-reads them. Run git add --renormalize . once after adding .gitattributes to apply the new rules to already-tracked files, then commit the result.
Is this private?
Yes. Everything runs entirely in your browser — your selections and custom rules are never uploaded to a server.
For the companion file that also matters for consistent line endings and indentation, see the EditorConfig Generator. To generate the file that keeps generated artifacts out of your repo entirely, use the Gitignore Generator. Need to convert line endings in files you already have, rather than declare a rule for future ones? Try the CRLF/LF Line Ending Converter.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/gitattributes-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"eolMode": "auto",
"groupLanguagesRuntimes": "[\"presetNode\"]"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `gitattributes-generator` tool (.gitattributes Generator) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.