How To Change GitHub Repository Language For Java Projects

Suren K
TechInPieces
Published in
2 min readDec 18, 2018

--

The Solution / TL;DR

Add a new file named .gitattributes at the root level, to your master branch in your repository

Add the below lines to the file:

*.java linguist-detectable=true
*.js linguist-detectable=false
*.html linguist-detectable=false
*.xml linguist-detectable=false

Save and refresh your browser. You will be able to see your Java project marked correctly. Also you can add more types of files to be ignored.

The example .gitattributes file for my Java Examples project on GitHub

Why this post?

Because i was struggling to get GitHub show my Java project as “Java” and not as any other language. Without the above .gitattributes file, my project was being shown/tagged as HTML , javascript or CSS project. I understand that my Java project has all those files in it, but..

GitHub will NOT be able to identify the primary programming language

So we need to explicitly tell it.

I was researching a lot about GitHub Linguistics etc but i could not find a good example that works for Java projects.

And frankly i could not understand linguist-vendored , linguist-detectable

--

--

Suren K
TechInPieces

Software Engineering Manager, Programmer, Architect, Inventor, Speaker and Writer. Works @Capgemini https://surenk.com