GitHub search allows filtering repositories by language. How can I set a repository to a specific language?
-
Possible duplicate of [Github changes repository to wrong language](https://stackoverflow.com/questions/34713765/github-changes-repository-to-wrong-language) – Saif Siddiqui Sep 10 '19 at 05:15
7 Answers

- 1
- 62
- 391
- 407
-
1This is good info, but note that it says: "Please note that the overrides currently only affect the language statistics for a repository and not the syntax-highlighting of files." So if you're looking to alter the syntax highlighting, alas, this won't help... – shmim Jan 06 '15 at 20:14
-
7...but it solves the question asked - change the overall repo language. – CAD bloke Mar 24 '15 at 22:33
-
2
-
Worked perfectly. "*.cls" was in my case incorrectly categorized as Apex. Changed: `*.cls linguist-language=openedge-abl` (and `*.p`, `*.i`, `*.w`) -> done. – Tw Bert Nov 09 '17 at 21:15
-
-
1
It is purely deduced from the code content.
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

- 30,738
- 21
- 105
- 131

- 1,262,500
- 529
- 4,410
- 5,250
-
2[cell303](http://stackoverflow.com/users/870615/cell303) comments that "However, if you put your libs into a folder named `vendor` the bytes won't be counted.". To be verified. – VonC Jul 13 '13 at 06:26
-
Just to supplement this, here is the link to the [linguist documentation](https://github.com/github/linguist#overrides) – ehiller Apr 02 '17 at 16:17
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.

- 697
- 6
- 10
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.

- 30,738
- 21
- 105
- 131

- 2,201
- 1
- 13
- 18
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.

- 30,738
- 21
- 105
- 131

- 1,125
- 13
- 20
-
14@HaroldoGondim did you ever figure out the answer to your question? i hate when people write answers like this and don't actually give you all of the necessary information especially when the instructions are to add things to a file... which file?!? – Anthony Oct 23 '16 at 03:41
-
1you don't have to add these code lines anywhere, github handles this for you, just put your libraries in a `vendors` or `thirdparty` folder and they won't be analysed. – Nicolas Oct 25 '16 at 07:54
-
You can now choose the files excluded using [Linguist overrides](https://github.com/github/linguist#overrides). No need to move the files around. – pchaigno Aug 13 '17 at 07:20
Create .gitattributes file in the root of your folder. Suppose you want the language to be Java, just copy-paste
*.java linguist-detectable=true
*.js linguist-detectable=false
*.html linguist-detectable=false
*.xml linguist-detectable=false
in the .gitattributes file and push the file in the repository. Reload your GitHub page to see the language change.
For reference, use this GitHub repository.

- 424
- 8
- 16

- 856
- 1
- 13
- 33
Rename the name of the code files in your repository with the extension added.
For example:
- change abc to abc.py for Python
- abc to abc.java for Java files
- abc to abc.html for HTML

- 30,738
- 21
- 105
- 131

- 100
- 5
-
4Renaming codefiles for the purpose of Github recognition is a bit backwards, hence the downvotes, most likely. – jeffmcneill Mar 16 '17 at 10:19