.GITATTRIBUTES EXPLAINER · RUNS IN YOUR BROWSER · NOTHING UPLOADED

Which line sets this attribute, and why does my .gitattributes line do nothing?

Paste your .gitattributes files and a list of paths. For every path you get every attribute and the line that set it, resolved the way git check-attr resolves it: macros such as binary expanded, deeper files beating shallower ones, .git/info/attributes on top. The tool flags the lines git silently drops (a ! pattern, an [attr] macro in a subfolder, one invalid name), docs/ patterns that never reach a file, Git LFS lines without -text, misspelled attributes, and says what git will do to each file's line endings under your core.autocrlf.

Nothing you paste leaves this browser tab. Checked against git check-attr and git ls-files --eol on thousands of random repositories, and against real commits and checkouts for line endings (see the README); still, your own git is the final word.

1. Your attribute files

Paste your root .gitattributes. For more files, start each with a line ==> path/to/.gitattributes <== (what head prints for several files, so head -n 1000 $(git ls-files '*.gitattributes') gives you the whole lot). ==> .git/info/attributes <== and ==> core.attributesFile <== (your global file) work too.

Two corners differ by version: git 2.44 started rejecting attribute names that begin with builtin_, and git 2.52 changed how a ** glued to text (/a**/b) matches.

2. The paths to check, and your line-ending settings

From git ls-files (or git ls-files --eol, whose columns are read too). End a line with / to check a folder itself.

git config core.autocrlf and git config core.eol print yours; nothing printed means the default.

Why does one path get these attributes?

Every line that matches the path, in the order git reads them, and what each attribute on it did.

    From a terminal

    The same engine runs over a whole repository, with no install and no network: it reads every .gitattributes, .git/info/attributes, your global attributes file, core.autocrlf, core.eol and the file list itself. --verify asks your own git about every path and reports any answer that differs.

    node ventures/gitattributes-explainer/cli/check.mjs             # report
    node ventures/gitattributes-explainer/cli/check.mjs --why path  # every attribute of one path, and why
    node ventures/gitattributes-explainer/cli/check.mjs --verify    # compare with git check-attr
    node ventures/gitattributes-explainer/cli/check.mjs --strict    # exit 1 on a high finding (CI)

    Clone the source, then run it from inside your own repository with the path to cli/check.mjs. Node 18 or later.

    Questions

    Why does my .gitattributes line do nothing?

    The five usual causes: the pattern ends in a slash (docs/ matches the folder, never the files in it; write docs/**), the line starts with ! (negative patterns are not allowed in .gitattributes, so git drops the line), it defines an [attr] macro in a .gitattributes below the root (macros only work at the top level), it has a misspelled or invalid attribute name (one invalid name drops the whole line), or it changes line endings for files that were committed before it, which git does not rewrite until you run git add --renormalize. The tool flags the first four and shows, path by path, which line decided each attribute.

    How do I exclude one path from a .gitattributes rule?

    Not with !: .gitattributes has no negative patterns. Add a line for the path after the broad one and switch the attribute off with a minus, as in vendor/ours/** -linguist-vendored, or back to unspecified with an exclamation mark before the attribute name, as in vendor/ours/** !linguist-vendored. Later lines win within a file, and a deeper .gitattributes wins over the root one.

    Which line in .gitattributes wins?

    For each attribute separately, git takes the first line that decides it in this order: .git/info/attributes, then the .gitattributes in the path's own folder, then each parent folder up to the root, then your global attributes file and the system one. Within a file the last matching line wins, and on one line a later attribute beats an earlier one. git check-attr -a path prints the result for one path; this tool prints it for every path, with the deciding line.

    Why are my line endings not changing after I edited .gitattributes?

    Attributes apply when git reads or writes a file, so files committed earlier keep the line endings they were stored with. Run git add --renormalize . and commit to re-store them under the new rules, then check out again to rewrite your working copy. Also check the value: git only understands eol=lf and eol=crlf in lower case, and text=auto or text, so eol=CRLF or text=true is ignored.

    What should a Git LFS line in .gitattributes look like?

    git lfs track writes pattern filter=lfs diff=lfs merge=lfs -text. The -text matters: without it, a broader * text=auto line can apply line-ending conversion to the file. The tool flags LFS lines that leave text set.

    Is anything I paste uploaded?

    No. The checker runs entirely in this browser tab. There are no accounts, cookies or analytics vendors, and the command-line version makes no network calls.