Changing repository language on GitHub
Asked Answered
F

2

17

I've noticed that Github picked JavaScript as the language for my Django app:

enter image description here

Is it possible to change it to Python? Or do I need to make a new repository?


Solved:

As @Geno Chen said, to change the repository language we have to add the file .gitattributes containing this code:

# to change language of repo from Javascript to Python
    *.js linguist-language=Python
Fizgig answered 1/3, 2019 at 14:2 Comment(3)
Possible duplicate of Github language tagAphanite
Possible duplicate of How to change the language of a repository on GitHub?Snuffle
Possible duplicate of Github changes repository to wrong languageConvergent
T
16

The language detector stats the programs in your projects and shows the result with the ratio. If your repository have detected a wrong language, you can follow the tutorial, most of the time you just need to override the result with a .gitattributes in the repository root containing something like the sample from tutorial, to manually pull up the ratio of specific programming language:

# Example of a `.gitattributes` file which reclassifies `.rb` files as Java:
*.rb linguist-language=Java
Toscano answered 1/3, 2019 at 14:14 Comment(3)
This solution didn't work for me. I'm using tailwind CSS for my JS based web project. It shows 97% css and rest as JS. I've added *.js linguist-language=JavaScript inside ".gitattributes" but it didn't fixPignus
@Pignus Asking GitHub for seeing JS files as JavaScript files are obviously useless. It seems you need to ask GitHub for seeing CSS files as JavaScript files.Toscano
*.css linguist-detectable=false fixed partially as CSS is shown 0% with this, not sure if there is bug with GH language detection libraryPignus
H
10

Create a new file in your repo and name it to .gitattributes. After that make sure you set linguist-detectable to truelike this:

*.css linguist-detectable=false
*.java linguist-detectable=false
*.python linguist-detectable=true 
*.js linguist-detectable=false
*.html linguist-detectable=false  
*.xml linguist-detectable=false 
Hilltop answered 4/6, 2020 at 23:56 Comment(2)
simple and straightforward answer. It perfectly worked for mePennyworth
makes more sense than the accepted answer thank youAmimia

© 2022 - 2024 — McMap. All rights reserved.