How can I change the language of a repository on GitHub?
GitHub search allows filtering repositories by language. How can I set a repository to a specific language?
Solution 1:
You can also override certain files
$ cat .gitattributes
*.rb linguist-language=Java
Source
Solution 2:
It is purely deduced from the code content.
As Pedro mentions:
Please note that we count the total bytes of each language's file (we check the extension) to decide the percentages.
This means that if you see your project reported a JavaScript, but you swear you use Ruby, you probably have a JS lib somewhere that is bigger than your Ruby code
As detailed in "GitHub changes repository to the wrong language", you can add a .gitattributes
file in which you can:
-
ignore part of your project (not considered for language detection)
static/* linguist-vendored
-
consider part of your project as documentation:
docs/* linguist-documentation
-
indicate some files with specific extension (for instance
*.rb
) should be considered a specific language:*.rb linguist-language=Java
Solution 3:
You can also make some of the files vendor
-ed. Just create a .gitattributes
file in the main directory. If you want to exclude CSS from the language statistics write into the file something like this.
client/stylesheets/* linguist-vendored
This will hide all files in the client/stylesheets/
from the language statistics. In my case these are the .css files.
This solves your problem partly, because hides the most used language and choose the second one to be prime.
Solution 4:
A bit brute-force, but I used this .gitattributes file:
* linguist-vendored
*.js linguist-vendored=false
It says to ignore all files except .js, so JavaScript becomes the only possible language. My project, https://github.com/aim12340/jQuery-Before-Ready, was listed as HTML and this changed it to JavaScript.
Solution 5:
As VonC mentioned in the comments, you can put your libraries under "vendors" or "thirdparty" and the files won't be analysed by linguist, the tool GitHub uses to analyse the language in your code.
# Vendored dependencies
- third[-_]?party/
- 3rd[-_]?party/
- vendors?/
- extern(al)?/
Later, they added more folder names.