So I have a git repository that I wrote in C++, but github insists that I'm using D. Why is this and is there someway to correct it?
-
5+1 I was always wondering why/how GitHub gets it wrong. – Jun 23 '13 at 17:57
-
Where exactly does it say so? – Nawaz Jun 23 '13 at 18:03
-
@Nawaz if you have the new github it will show up as a big yellow bar across the page. Click on it and it will say D 98.9% – Loourr Jun 23 '13 at 18:06
-
When we are at it, I'm always wondering where in [my code](https://github.com/griwes/ReaverOS) github found Objective C... – Griwes Jun 24 '13 at 17:43
-
13You sure it's not a grade? – Kevin Jun 24 '13 at 17:43
-
1(Just kidding, just kidding) – Kevin Jun 24 '13 at 17:44
2 Answers
Github uses it's own language parsing module and sometimes (actually often) it makes faults. Just write more code to make it easier for parser to choose what your main language is and after some time github will get it right.
In this particular case code parser is fooled by your files in STMC-C/Assignments/a*
dirs with .d
extension. That's an extension for D sources. The number of this sources dominated in your project so github decided that the main programming language used is D.
edit: Just found this public repo (github language detector) - it has some explanations of the system.

- 14,395
- 10
- 44
- 68
-
that makes sense though it seems silly still because there are significantly more files with `.cpp` extensions, and as the project consists of several thousand lines of exclusively c++ code I'm not sure if there is anything to be done about it. – Loourr Jun 23 '13 at 18:05
-
8@Loourr A simple find/cat/wc shows your `.d` are 160259 lines in your repository, out of 163404 lines total. You've got 8 `.d` files each consisting of 20000 lines, that's massively more than your C++ code. (Yes, I realise those `.d` files don't contain code.) – Jun 23 '13 at 18:29
-
3@hvd good point, I think what I'll do is just add them all to my `.gitignore` file, because there all computer generated anyway – Loourr Jun 23 '13 at 18:38
-
@hvd - check out [cloc](http://cloc.sourceforge.net/). FWIW, `find -exec wc -l {} +` would be simpler, and give more info. Hope this helps! – beatgammit Jul 05 '13 at 01:43
You could create a file .gitattributes
to set GitHub's Linguist overrides.
To set your C++ files to be detected as C++ by extension:
*.h linguist-language=C++
*.cpp linguist-language=C++
To ignore generated files and don't show them in diffs:
generated/*.d linguist-generated=true
Also, you can mark some files as undetectable, if the language is not on the known languages list:
*.t linguist-detectable=false

- 7,580
- 1
- 38
- 49