Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to exclude files from git language statistics?

Tags:

github

Silly question and not on something that is so necessary, but is it possible to exclude files from Github's language statistics aggregation on top?

I have checked some external CSS and JavaScript frameworks to be compressed along with the rest of the source code. They get measured as part of the project although they have not been contributed from a team member. This means that the status bar does not reflect the exact state of the project.

like image 349
Dimitrios Mistriotis Avatar asked Sep 27 '13 14:09

Dimitrios Mistriotis


People also ask

How do I exclude files from a Git repository?

Open the . git/info/exclude file in a text editor and add the folder to ignore. This file remains private to you.

What files should not be stored in git?

You shouldn't store credentials like usernames, passwords, API keys and API secrets. If someone else steals your credentials, they can do nasty things with it.

How does GitHub detect language?

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.

How do I exclude a folder from GitHub?

To ignore files in your repository with GitHub Desktop go to the Repository menu and select Repository Settings… With the Repository Settings pop-up open, click the Ignored Files tab. Here you will be able to add file names, directory names, or patterns for Git to ignore in your repository.


2 Answers

GitHub uses the Linguist library for source code detection; Linguist treats all of the paths defined in its' vendor.yml as vendored and won't include them in the language statistics for a repository.

Update:

From comments below, currrent instructions are here: https://github.com/github/linguist/blob/master/docs/overrides.md

Original answer:

You can specify something different for your repo by editing your repo's .gitattributes file. To treat a path as a vendored file, add the path followed by linguist-vendored:

special-vendored-path/* linguist-vendored 

To treat an otherwise vendored path as unvendored, use linguist-vendored=false:

jquery.js linguist-vendored=false 

Source

like image 130
Eugene Fidelin Avatar answered Sep 27 '22 23:09

Eugene Fidelin


From the Github Help page My repository is marked as the wrong language:

Linguist excludes certain file names and paths from statistics. Check out the vendor.yml file for a list of these exclusions.

Pull requests with new exclusion patterns are always welcome.

So if your javascsript/css files match a regexp in that Yaml file they shouldn’t be included in the stats. If they don’t, you could add them and create a pull-request.

like image 26
matt Avatar answered Sep 28 '22 00:09

matt