



My repository is detected as the wrong language

language stats bar

The Language stats bar is built by aggregating the languages of each file in that repository. If it is reporting a language that you don't expect:

  2. If you see files that you didn't write, consider moving the files into one of the paths for vendored code, or use the manual overrides feature to ignore them.
  3. If the files are being misclassified, search for open issues to see if anyone else has already reported the issue. Any information you an add, especially links to public repositories, is helpful.


Linguist supports a number of different custom overrides strategies for language definitions and vendored paths.

Using gitattributes

Add a .gitattributes file to your project and use standard git-style path matchers for the files you want to override to set linguist-documentation, linguist-language, and linguist-vendored. .gitattributes will be used to determine language statistics, but will not be used to syntax highlight files. To manually set syntax highlighting, use Vim or Emacs modelines.

$ cat .gitattributes
*.rb linguist-language=Java

Checking code you didn't write, such as JavaScript libraries, into your git repo is a common practice, but this often inflates your project's language stats and may even cause your project to be labeled as another language. By default, Linguist treats all of the paths defined in lib/linguist/vendor.yml as vendored and therefore doesn't include them in the language statistics for a repository. Vendored files are also hidden by default in diffs on

Use the linguist-vendored attribute to vendor or un-vendor paths. Please note, overriding the vendored (or un-vendored) status of a file only affects the language statistics for the repository and not the behavior in diffs on

$ cat .gitattributes
special-vendored-path/* linguist-vendored
jquery.js linguist-vendored=false

Similar to vendored files, Linguist excludes documentation files from your project's language stats. (Unlike vendored files, documentation files are displayed in diffs on lib/linguist/documentation.yml lists common documentation paths and excludes them from the language statistics for your repository.


$ cat .gitattributes
project-docs/* linguist-documentation
docs/formatter.rb linguist-documentation=false

Using Emacs and Vim modelines

Alternatively, you can use Vim and Emacs style modelines to set the language for a single file. Modelines can be placed anywhere within a file and are respected when determining how to syntax-highlight a file on

vim: set filetype=prolog:
vim: set ft=cpp:

-*- mode: php;-*-


Install the gem:

$ gem install github-linguist

Then use it in your application:

require 'rugged'
require 'linguist'

repo ='.')
project =, repo.head.target_id)
project.language       #=> "Ruby"
project.languages      #=> { "Ruby" => 119387 }

These stats are also printed out by the linguist executable. You can use the --breakdown flag, and the binary will also output the breakdown of files by language.


$ bundle exec linguist --breakdown

100.00% Ruby



Please check out our contributing guidelines.