Smart Deals - promotions, discount codes and sales

Gitattributes Generator

Define text normalization, safe script EOL, binary patterns, Git LFS, and release archive rules.

Secure (SSL)
Client-Side Processing
100% Free
Instructions
  • 1
    Enter data
    Enter content, paste text or load a file from disk.
  • 2
    Click the button
    The tool will immediately process your data in the browser.
  • 3
    Get the result
    Copy the finished text or save the file to your device.
function runTool() {
  return "Result ready in 0.1s";
}
Set the options and generate a .gitattributes file.

Rate this tool:

Related tools

Other tools you may find useful

Gitattributes generator for consistent EOL, binary files, and Git LFS

Gitattributes Generator builds a repository file-handling policy for Git. It configures automatic text detection, a chosen line ending, safe overrides for POSIX and Windows scripts, a broad set of binary formats, optional Git LFS patterns, and paths excluded from git archive.

How Git interprets attributes

Each line combines a path pattern with attributes. The rule * text=auto eol=lf asks Git to detect text, normalize it in the index, and write LF in the working tree. The crlf alternative keeps normalized repository data while checking text out with CRLF. When automatic normalization is disabled, the generator truly omits the global rule instead of silently adding another text=auto.

RuleMeaningTypical use
text=autoDetect and normalize text automaticallySource code, configuration, and documentation
eol=lfWrite LF in the working treeShell, Linux, containers, and CI
binaryShortcut for -diff -merge -textImages, fonts, archives, audio, and video
filter=lfsApply Git LFS pointer filtersLarge assets that must remain versioned
export-ignoreOmit a path from an archiveTests and repository-only configuration

Line endings and executable scripts

A global choice must not break scripts. The generator therefore always adds *.sh, *.bash, and *.zsh text eol=lf. An interpreter reads the shebang from the first line; CRLF can leave an invisible \r in the interpreter path and fail with a “bad interpreter” error. Windows *.bat and *.cmd files explicitly receive eol=crlf.

An EOL attribute does not set executable permissions. The executable bit is a separate Git index property; on Unix, set it with chmod +x file.sh followed by git add file.sh. Repeat repository automation rules with the GitLab CI Generator.

Binary files without misleading diffs

The generated list covers common PNG, JPEG, GIF, WebP, AVIF, and ICO images, PDF documents, fonts, archives, media, and executable libraries. The binary macro disables text conversion and automatic merging. SVG is intentionally absent because it is text-based XML and a meaningful diff can be useful. JSON, YAML, and source files remain text as well.

Explicit patterns communicate intent better than heuristics alone, but they do not compress files or shrink history. Build artifacts that do not belong in the index should be excluded before commit with the Gitignore Generator. Optimize application images when possible instead of sending every asset to LFS by default.

Git LFS patterns and validation

When LFS is enabled, every nonempty line receives filter=lfs diff=lfs merge=lfs -text, and duplicate patterns are removed. The tool rejects control characters, whitespace, a leading !, a leading comment marker, trailing slashes, and lists above 50 entries. Those forms are ambiguous or do not behave in attributes as many users expect.

The attributes alone do not migrate existing history or install the extension. Every contributor and CI runner needs Git LFS, and the repository needs initialization. Before committing, inspect a path with git check-attr -a -- path and review git lfs track. Do not use LFS for mergeable files such as source code, manifests, or small SVG documents.

Deploying and renormalizing the repository

  1. Choose LF for projects deployed on Linux, or deliberately select CRLF for Windows-oriented working text.
  2. Keep text=auto unless the repository already has a detailed extension-by-extension policy.
  3. Enable LFS only for specific large formats and remove patterns the project never stores.
  4. Save the output as .gitattributes at the repository root, then run git add --renormalize ..
  5. Review the diff and commit normalization separately from logic changes so code review remains understandable.

Align editor behavior with the EditorConfig Generator, and repeat important consistency checks through the GitHub Actions Generator. EditorConfig influences how an editor saves a file; gitattributes controls how Git stores and checks it out. They complement each other.

Release archives with export-ignore

The archive option marks .github, tests, phpunit.xml, .gitignore, and .gitattributes with export-ignore. This affects only git archive. It does not remove files from the repository, a clone, or an archive made by a generic ZIP application. Verify a release with git archive HEAD | tar -tf - before publishing.

Frequently asked questions

Will existing line endings change immediately?

Not in the current index. Run git add --renormalize ., review the diff, and commit it. Future checkouts then follow the declared policy.

Do binary and Git LFS mean the same thing?

No. binary disables text behavior while content remains in ordinary Git objects. LFS replaces content with a small pointer and stores the data in a separate service.

Why do shell scripts always use LF?

CRLF can append a carriage return to the interpreter path in a shebang and prevent execution. An explicit LF override protects scripts even when global working-tree text uses CRLF.

Can I enter a directory as an LFS pattern?

A trailing slash does not work recursively in attributes. Use a file pattern such as assets/** or assets/**/*.psd, depending on what the repository actually needs.

Does .gitattributes replace .editorconfig?

No. Git normalizes data during add and checkout, while EditorConfig guides the editor during save. Align EOL settings in both files to avoid recurring local modifications.

Install Webp.pl Have the tools in your own pocket!