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
Kin
  • 1,435
  • 10
  • 16
  • Possible duplicate of [Github language tag](https://stackoverflow.com/questions/3305147/github-language-tag) – Justinas Mar 01 '19 at 14:13
  • Possible duplicate of [How to change the language of a repository on GitHub?](https://stackoverflow.com/questions/13597892/how-to-change-the-language-of-a-repository-on-github) – Saif Siddiqui Aug 15 '19 at 04:10
  • Possible duplicate of [Github changes repository to wrong language](https://stackoverflow.com/q/34713765/3345375) – jkdev Aug 15 '19 at 05:28

2 Answers2

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
Geno Chen
  • 4,916
  • 6
  • 21
  • 39
  • 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 fix – vikramvi May 05 '21 at 10:36
  • 1
    @vikramvi 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. – Geno Chen May 05 '21 at 11:10
  • 1
    *.css linguist-detectable=false fixed partially as CSS is shown 0% with this, not sure if there is bug with GH language detection library – vikramvi May 05 '21 at 11:18
9

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 
Mo Fatah
  • 159
  • 1
  • 11