How to change the GitHub repository language ?

James George
2 min readApr 19, 2018

--

GitHub uses the linguist library to detect languages begin used in a particular repository, ignore vendored files and and generate language breakdown graphs. Linguist takes the list of languages it knows from languages.yml file and uses a number of methods to try and determine the language used by each file, and the overall repository breakdown.

It often happens that your repository language may not be interpreted correctly. This happens because the linguist library compares the percentage composition of each language used within the repository and sets the one which dominates which may not be the right case.

This happened to me as I was building up my own Social Media platform backed up by PHP and MySQL. Major part of the repository was dominated by stylesheets since I had linked css libraries like Bootstrap, Animate.css etc. which was misinterpreted by the linguist library and the repo language was set as css instead of PHP.

After a bit of research on the topic I came across a very simple solution of explicitly overriding what is already there. I created a .gitattributes file with the following content: ` *.css linguist-language=PHP`

Now the whole css part is considered as that of PHP which changes the repo language. You may refer my repository to see the how the changes took effect: https://github.com/jamesgeorge007/Mini-Social-Media

For more reference: https://github.com/github/linguist

--

--