Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Files and Formats

The linguist attributes

Reference for linguist-vendored, linguist-generated, linguist-documentation, linguist-detectable and linguist-language: hints GitHub uses for language statistics.

The linguist-* attributes are not part of Git itself. They are hints for Linguist, the library GitHub uses to detect languages, draw the language bar on a repository page and collapse diffs of generated files. You write them in .gitattributes like any other attribute, and Git simply stores and reports them; only GitHub (and tools built on Linguist) act on them.

Use them when the detected languages are misleading: a vendored library dominating the statistics, a bundled build output cluttering pull requests, or a custom file extension being misread.

Terminal
vendor/**        linguist-vendored
dist/**          linguist-generated
docs/**          linguist-documentation
*.inc            linguist-language=PHP
*.txt            linguist-detectable

Try it

Bash Git stores and reports the hints

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Override one file and unset a rule

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
<pattern> linguist-vendored[=true|false]
<pattern> linguist-generated[=true|false]
<pattern> linguist-documentation[=true|false]
<pattern> linguist-detectable[=true|false]
<pattern> linguist-language=<Language Name>
Attribute Effect on GitHub
linguist-vendored Excludes matching files from language statistics (third-party code).
linguist-generated Excludes the files from statistics and collapses their diffs in pull requests.
linguist-documentation Excludes the files from statistics; treated as documentation.
linguist-detectable Forces the file's language to count, even for types normally ignored (prose, data).
linguist-language=<name> Overrides the detected language, using the name from Linguist's list, such as Markdown or C++.

Each boolean attribute can be set (linguist-vendored), set to true/false, or unset (-linguist-vendored).

Edge cases: the last matching line wins, and attributes set in .gitattributes in the repository root apply to the default branch for the language bar. Unknown language names are ignored.

Usage notes

  • Git ignores the meaning. git check-attr prints them, but nothing in Git changes. Other hosts may ignore them entirely.
  • They affect statistics, not content. The files stay in the repository and in clones.
  • Statistics update on push to the default branch, and caches can delay the change by a short time.
  • Prefer directory patterns with **. vendor/** matches every file below; vendor alone may not match as you expect.
  • Generated files are still reviewed. Collapsing a diff hides it by default but does not stop it from being merged; review the generator input instead.
  • Combine with -diff for bundles you never want to read as text; see diff and merge attributes.
  • Language overrides are per pattern. A *.inc rule affects all .inc files, including ones that really are something else.