Paul Razvan Berg
Paul Razvan Berg

Reputation: 21410

How to make GitHub not count some files for the programming language distribution?

If you tap the multi-colored bar underneath the "commits/branch/..." tab bar in a GitHub repo page, you get this distribution of programming languages:

GitHub repo programming language distribution

I'd like to mark some JavaScript files as strictly templates and not source code, so that TypeScript will grow to be the longest in this bar chart. Is this possible?

Upvotes: 4

Views: 340

Answers (1)

VonC
VonC

Reputation: 1324537

GitHub uses linguist to make the content of the "multicoloured bar underneath".

You can use overrides with .gitattributes directive

Linguist supports a number of different custom override strategies for language definitions and file paths.

File and folder paths inside .gitattributes are calculated relative to the position of the .gitattributes file.

# Example of a `.gitattributes` file which reclassifies `.rb` files as Java:
*.rb linguist-language=Java

When testing with a local installation of Linguist, take note that the added attributes will not take effect until the .gitattributes file is committed to your repository.

lib/linguist/languages.yml does not include just "template", but you can chose another entry for the files you want to exclude from JavaScript.

Upvotes: 3

Related Questions