Github misclassifies Matlab .m files as Objective-C files
Asked Answered
A

2

7

I'm new to Git and I'm trying to push my local branch to the remote directory on Github. My project is on Matlab, so the files have .m extension. They naturally don't show any objective-c language pattern. I even checked in some .mat files. But they are misclassified as Objective-C files.

I would like to know:

  • After push, can we modify directly the language in Github? I'm sorry if it is very easy to find, but I really couldn't find that.

  • I find that other people's Matlab project could be correctly classified, with just .m extension. Some people also mentioned if you name your files with .matlab extension, it could be easily recognized as Matlab language, but it's not a clean solution. I would like to know, what are the criteria that files could be recognized as matlab with .m extension or just to increase the chance to be recognized as matlab language. I noted that some people just add matlab in their file name, but people who don't do that also succeeded.

I've sent an email to Github for help. They answered the first question: the answer is no.

GitHub determines the language based on the total size of the files that belong to each language. We use the Linguist library to analyze source code files: https://github.com/github/linguist

Alathia answered 25/11, 2012 at 21:30 Comment(0)
P
0

I suppose this is the same problem as in the webapps stack exchange: https://webapps.stackexchange.com/questions/31654/force-github-syntax-highlighting-language-on-source-files

Seems that the way to do that is to change from the ambiguous .m extention to .matlab, even though it's not prefered by the author...

Pycnometer answered 25/11, 2012 at 21:38 Comment(2)
Thanks, it seems the closest solution by now =)Alathia
There's now a way to change the language without touching the file: Linguist overrides.Remington
R
0

It is now possible to use Linguist overrides to override the detection results from Linguist. In particular, you can use a .gitattributes file in your repository:

*.m linguist-language=Objective-C

Note: If you're checking locally, you'll need to commit the .gitattributes file before you see the effect.

Remington answered 12/8, 2017 at 20:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.