.gitattributes Generator
Generate .gitattributes to normalize line endings, mark binaries, configure diff and override GitHub linguist language stats.
—
The file that tells Git how to treat each kind of file
.gitattributes is less famous than .gitignore and solves a different class of problem. Where ignore says what stays out of the repository, attributes says how Git should handle what is already in: which files are text and may have their line endings normalised, which are binary and should not be diffed line by line, and which should be excluded from the language statistics.
Tick the options that fit your project and the page assembles the file. The most valuable rule is usually the first: text=auto eol=lf normalises line endings to LF inside the repository, regardless of which system the commit came from. That puts an end to the classic diff showing the whole file as modified just because someone opened it in a Windows editor.
The remaining options cover images, PDFs and audio, marked as binary so Git stops trying to build a diff or merge content; dependency and build output folders, marked vendored and generated so they do not skew GitHub's language bar; and documentation, marked as such. Save the result as .gitattributes in the repository root. For files already committed with CRLF, you have to run git add --renormalize . once for the change to take effect.
Frequently asked questions
What is the difference between text=auto and core.autocrlf?
Does marking a file as binary change it?
What is linguist-vendored for?
Related Tools
Git Merge Conflict Resolver
Splits a file with Git conflict markers into ours and theirs versions, lets you pick a side per hunk and outputs the resolved file.
Git Cheatsheet
Searchable list of the most-used git commands — config, commit, branch, merge, rebase, stash, log, remote, reset. With copyable examples. Everything in your browser.
Git Aliases Generator
Useful git aliases (st, co, br, lg, undo, save, wip, amend, hist) ready to paste into .gitconfig.
.mailmap (Git) Generator
Map inconsistent names and emails to a single author in Git, improving stats and shortlog. Official format.
.gitignore Generator
Generate a .gitignore by combining language/IDE templates — Node, Python, Java, Go, Rust, .DS_Store, JetBrains, VSCode etc. Everything in your browser.
.git-blame-ignore-revs Generator
List of commit hashes for Git to ignore in blame (mass formatters: prettier, black, eslint --fix). Useful for large refactors.