Exclude Vendor Files from GitHub Statistics

Use linguist-vendored in .gitattributes to exclude third-party code from GitHub language statistics and hide it in pull request diffs.

Best Practices

Detailed Explanation

Linguist-Vendored Attribute

GitHub uses the Linguist library to calculate repository language statistics (the colored bar on the repository page). When third-party libraries, generated code, or vendored dependencies are included in the repository, they can skew these statistics dramatically.

The Attribute

# Third-party libraries
vendor/**           linguist-vendored
node_modules/**     linguist-vendored
third_party/**      linguist-vendored
external/**         linguist-vendored

# Vendored assets
public/assets/lib/** linguist-vendored
static/vendor/**     linguist-vendored

# Package managers
bower_components/**  linguist-vendored

Effects of linguist-vendored

Feature Without With linguist-vendored
Language statistics Counted Excluded
PR diff view Expanded Collapsed by default
Code search Indexed Still indexed
Git behavior No change No change

Note that linguist-vendored only affects GitHub's web interface. It has no effect on Git operations, line endings, or diffs in the terminal.

Real-World Example

A Go project that vendors its dependencies in vendor/ might show as 90% JavaScript because of a vendored library. Adding vendor/** linguist-vendored corrects the language bar to accurately reflect the project's own code.

linguist-vendored vs .gitignore

Approach Effect
.gitignore Files are not tracked by Git at all
linguist-vendored Files are tracked but excluded from statistics

Use .gitignore for files that should never be in the repository (like node_modules/). Use linguist-vendored for files that must be tracked but are not your own code (like Go's vendor/ directory).

Checking Current Statistics

You can verify your linguist configuration locally:

github-linguist --breakdown

This shows how GitHub will calculate your repository's language statistics.

Use Case

Repositories that vendor third-party dependencies (Go vendor/, Ruby vendor/bundle, or manually included JavaScript libraries) should mark those directories as linguist-vendored to maintain accurate language statistics on GitHub.

Try It — .gitattributes Generator

Open full tool