GitHub's language detection is done by the Linguist module, which is conveniently open source. It relies primarily on the file extension to detect the language, although it can be a bit clever to detect ambiguous files (such as .h
files). As you can see from the configuration file, .c
is firmly defined as a C file. Given the number of files that have to be assessed on GitHub, efficiency is a key requirement, if at the cost of some accuracy.
It looks like per repo configurations have been ruled out by the developer, so the only way you could make files syntax highlight as C++ would be to use C++ extensions. To keep those extensions and have highlighting you may have to try another service, or host the code somewhere yourself.
Update Oct 2014: GitHub haven't stood still, in the last year they have introduced some basic heuristics to help determine the language in the file. More specific to this questions, .c
files are now checked to see if they are C, C++ or Objective-C.
GitHub support's answer is a little interesting, they do use Pygments for highlighting and the lexer, but the rulesets are in their own Linguist module. Which you'd hope they'd know!