GitHub Repository Language Overview

undefined or mostly null.
Search for a command to run...

undefined or mostly null.
No comments yet. Be the first to comment.
In this series, I will share articles related to creating, contributing to, maintaining, and sustaining open source projects.
Git is a Free and Open Source Distributed Version Control System. By far, Git is the most widely used modern version control system in the world today. Git is a distributed and actively maintained open source project originally developed in 2005 by L...
I wrote this article in December 2023 for an interview screening task and thought to share it today while clearing my drafts for some new content prep, just in case it's still helpful to someone out t

Hey! I’m super excited to announce that I have joined the Secretariat Team at the Digital Public Goods Alliance. In this role, I leverage my passion for open source and technical background to assess DPG applications, provide technical support and ad...

Creative designs have become more important than ever in the software ecosystem today with many industries and end-consumers having several use cases that require them to offer design editing solutions to either designers or end-consumers. Every busi...

With the rise of artificial intelligence (AI) and large language models (LLMs), it has become easier to solve different human problems than ever before. Even consumers with little to no technical expertise can benefit from AI. Humans can now automate...

Some years ago, GitHub introduced the new Profile README feature that allowed GitHub users to pin a markdown file on their profile using a special repository named after their GitHub username. Since then, developers have used this file as a quick por...

The files and directories within a repository determine the languages that make up the repository. With GitHub, you can view a repository’s languages to get a quick overview of the repository. But how does this happen? What powers this repository language overview?
You might have noticed this section at the top of your GitHub repositories that give you an overview of languages contained in the repository.

Well, GitHub uses the open-source Linguist library to determine file languages for
syntax highlighting and repository statistics. Language statistics will update
after you push changes to your default branch (which is usually main).
GitHub Linguist is a library that is used on GitHub.com to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and generate language breakdown graphs. - GitHub Linguist Docs
Basically, Linguist is a library that runs on every GitHub repository. It checks every file and directory and detects the programming language used in that file.
Linguist takes the list of languages it knows from a languages.yml file and uses a number of methods to try and determine the language used by each file, and the overall repository breakdown.
Linguist starts by going through all the files in a repository and excludes all
files that it determines to be binary data, vendored code, generated code,
documentation, or are defined as data (e.g. SQL) or prose (e.g. Markdown) languages, whilst taking into account any overrides.
The result of this analysis is used to produce the language stats bar which displays the language percentages for the files in the repository. The percentages are calculated based on the bytes of code for each language as reported by the List Languages API.
Some files are hard to identify, and sometimes projects contain more library and vendor files than their primary code. If you’re receiving incorrect language analysis, then read below for common Linguist issues and how to fix them.
Linguist does not consider vendored code, generated code,
documentation, or data (e.g. SQL) or prose (e.g. Markdown) languages (as defined by the type attribute in languages.yml) when calculating the repository language statistics.
If the language statistics bar is not showing your language at all, it could be for a few reasons:
languages.yml e.g saving a JavaScript file as app.jssIf Linguist doesn’t know about the language or the extension you’re using, consider contributing to Linguist by opening a pull request to add support for your language or extension.
You can also tell Linguist to include your files in the language statistics by overriding it.
gitattributes to override LinguistJust as you can customize and override the default configurations of a gaming control pad, you can also use custom override strategies for language definitions and file paths in Linguist.
Basically, gitattributes is just a file used to command or tell Git to perform
some specific tasks, sort of a way to tweaking it. You can add a .gitattributes file to the root of your project like so:
touch .gitattributes
Now use the standard git-style path matchers for the files you want to override using the linguist-documentation, linguist-language, linguist-vendored, linguist-generated and linguist-detectable attributes.
When testing with a local installation of Linguist, take note that the added attributes will not take effect until the
.gitattributesfile is committed to your GitHub repository.
# .gitattributes file which reclassifies `.js` files as Java:
*.js linguist-language=Java
By default, Linguist treats all of the paths defined in
vendor.ymlas vendored and therefore doesn't include them in the language statistics for a repository.
special-vendored-path/* linguist-vendored
jquery.js linguist-vendored=false
project-docs/* linguist-documentation
docs/formatter.rb linguist-documentation=false
Not all plain text files are true source files. Generated files like minified JavaScript and compiled CoffeeScript can be detected and excluded from language stats.
Api.elm linguist-generated=true
Only programming languages are included in the language statistics. Languages of a different type (as defined in
languages.yml) are not "detectable" causing them not to be included in the language statistics.
*.kicad_pcb linguist-detectable=true
*.sch linguist-detectable=true
tools/export_bom.py linguist-detectable=false
Linguist defines the list of all languages known to GitHub in a yaml file. In order for a file to be highlighted, a language and lexer must be defined there.
If you experience any issue with Linguist, a quick way to get help is by contributing via Pull Requests or submitting an Issue.