šŸæ 2 min. read

How to Change Repo Language in GitHub

Monica Powell

How to Change Repo Language inĀ GitHub

Is GitHub telling you that your repository is 98.9% CSS or HTML when it isnā€™t? Hereā€™s how to resolve that issue everyĀ time.

I recently started working on a Weather app in Flask to auto-detect a userā€™s location based off of their IP address. After committing some updates to GitHub my app switched from being labeled as predominately Python to 98.9% CSS even though it was a Flask application in which most of the code I had written was in Python and HTML. Now and again, I do not agree with how GitHub classifies the languages in my repositories so I set out to figure out how to fix this issue.

Before: My Flask App Appeared in GitHub as 98.9%Ā CSS.

Pro-tip: Help GitHub properly detect your repositories main language(s).

GitHub has a linguist library that auto-detects the language within every repository. Upon researching how to resolve GitHub misclassifying the language of your projects I found out the solution is as simple as telling GitHub which files to ignore.

While you still want to commit these files to GitHub and therefore canā€™t use aĀ .gitignore you can tell GitHubā€™s linguist which files to ignore in aĀ .gitattribute file.

Upon examining the documentation for the linguist library I learned that adding just one line to aĀ .gitattributes file would resolve my language issues for this particular repo.

MyĀ .gitattributes:

1static/* linguist-vendored

This one-line file told GitHub to ignore all of my files in my static/ folder which is where CSS and other assets are stored for a Flask app. Vendor files can sometimes take up a lot of relative space so I am telling the linguist to just ignore them (since they were accounting for 98.9% of my project)!

After: My Flask App Appears in GitHub now as 56.2% Python and 43.8%Ā HTML.

Hereā€™s a repository by @with sampleĀ .gitattributes files for you try the next time you disagree with the linguistĀ ;). Note: Updates to theĀ .gitattributes may not apply retroactively and if linguist truly is wrong GitHub encourages you to report it as an issue in their /linguist repo.

I hope this article was helpful! I would love to hear some of your tricks for GitHub and am happy to answer any questions you may have.

If you enjoyed reading this article consider tapping the clap button šŸ‘. Wanna see more of my work? Check out my GitHub to view my code and learn more about my development experience at http://aboutmonica.com.

This article was published on February 07, 2017.


Don't be a stranger! šŸ‘‹šŸ¾

Thanks for reading "How to Change Repo Language in GitHub". Join my mailing list to be the first to receive my newest web development content, my thoughts on the web and learn about exclusive opportunities.

    Ā 

    I wonā€™t send you spam. Unsubscribe at any time.

    Webmentions

    1