I wrote a program in Python and used Bootstrap for its frontend.
When I upload the directory on GitHub it shows that the project is 90% JavaScript and only 7.5% Python. I understand that this is happening because of the JS directory in the Bootstrap folder.
I need to display Python as the primary project language for the repo.
I did a little bit of research and learnt that adding the file .gitattributes
to your project is a solution, but I have no idea what to add in that file to get Github ignore JavaScript when assessing the primary language of the project.
I checked out the official .gitattributes manual page but couldn't find a direct solution to this issue.
Here's what the repo looks like
Link to Github repo
Edit: All the CSS and JS files are in the static/
folder, so I added a .gitattributes
file to the repo and added static/* linguist-vendored
in the first line, however the repo still shows JS as 90% of the language.
You cannot change the language of the repository, but you can change the attributes of the github repository. I mean that if you have a project where there are 60% css and 40% javascript you can said to github-linguist, that you want to ignore the css file. this attributes ignore the java files.
GitHub uses the open source Linguist library to determine file languages for syntax highlighting and repository statistics. Language statistics will update after you push changes to your default branch.
gitattributes file allows you to specify the files and paths attributes that should be used by git when performing git actions, such as git commit , etc. In other words git automatically saves the file according to the attributes specified, every time a file is created or saved.
I did find if you go to 'Add topics' on the far left under the 'Code' section, you can add all the languages you used for anyone that might be looking close enough at your project.
The official gitattributes
documentation won't say anything about this since it's a GitHub-specific feature. Git itself doesn't do language statistics.
GitHub uses a tool called Linguist for language statistics, and Linguist allows you to specify paths it should ignore using a custom linguist-vendored
attribute:
Checking code you didn't write, such as JavaScript libraries, into your git repo is a common practice, but this often inflates your project's language stats and may even cause your project to be labeled as another language. By default, Linguist treats all of the paths defined in
vendor.yml
as vendored and therefore doesn't include them in the language statistics for a repository.Use the
linguist-vendored
attribute to vendor or un-vendor paths.$ cat .gitattributes special-vendored-path/* linguist-vendored jquery.js linguist-vendored=false
Note that the effects of this change can take some time to appear:
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.
Give GitHub a day or two to catch up after you've changed your .gitattributes
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With