Why is this file being treated like text? This tells you.
Tells you which .gitattributes rules apply to a given path. The answer to 'why is git treating this file as text/binary/whatever?'.
Think of it as a query tool against the attribute resolution engine. Same precedence as the actual checkout uses: per-directory .gitattributes, then $GIT_DIR/info/attributes, then global. check-attr just reports the result.
git check-attr [-a | <attr>...] [--cached] [-z] [--stdin] [--] <pathname>...
Output format:
<path>: <attr>: <value>
where <value> is set | unset | unspecified | <string>| Flag | What it does |
|---|---|
-a, --all | Show every attribute defined for the path. Don't pass attrs explicitly. |
--cached | Use attributes from the index, not the working tree (matches what checkout/diff sees in CI). |
--stdin | Read paths from stdin. Pair with -z for NUL-separated paths. |
-z | NUL-separate input and output. Use whenever paths could contain newlines. |
<attr>... | Specific attributes to query (e.g. text eol diff). Faster than -a. |
git check-attr -a path/to/file.cgit check-attr text eol diff README.mdgit ls-files -z | git check-attr --stdin -z -agit check-attr --cached -a generated/output.binHit each option, then Check answers. Score is recorded; Next is always open.