3

I own a Github repository which has a collection of scripts/programs in different languages to perform a task. The problem is that by default, my repository is marked to be in single language. I googled and tried to fix it with the .gitattributes file.

* linguist-vendored
*.py linguist-vendored=false

This piece of code helped me to mark Python as the default language, but I still want my repo to be marked with more languages. Is there a way around to achieve this? Or there can only be one language marked with a repository? Thanks.

cht
  • 319
  • 3
  • 13

1 Answers1

4

GitHub's language-detection has its own rather lengthy README.md file that you will also see below the contents of the repository itself. As it notes, it can detect multiple different languages and display them:

Image desc

but:

Linguist ... excludes all ... vendored code

and by writing:

* linguist-vendored

you have directed it to ignore all files. Your subsequent directive of:

*.py linguist-vendored=false

overrides this directive specifically for *.py files, allowing them to be classified.

The odd thing is that you bothered to add a .gitattributes at all. You need only do this if you must hide files or override the automated detection. What you did was hide all non-*.py files, so you are applying automated detection (not an explicit language override) for files that do match the *.py pattern.

You should also make particular note of their remarks that:

When you push changes to a repository on GitHub.com, a low priority background job is enqueued to analyze your repository as explained above. The results of this analysis are cached for the lifetime of your repository and are only updated when the repository is updated. As this analysis is performed by a low priority background job, it can take a while, particularly during busy periods, for your language statistics bar to reflect your changes.

(emphasis mine)

torek
  • 448,244
  • 59
  • 642
  • 775