Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force github recognizing files as written in a specific language?

I am writing a program in C which uses header files. These header files contain some structure declarations and, as C structures and C++ are pretty much the same, GitHub recognizes these files as C++ file, while I want them to be recognized as C files.

Is there a way to force GitHub recognizing header files as C files instead of C++ files?

like image 745
papillon Avatar asked Sep 19 '25 12:09

papillon


1 Answers

Github uses the linguist library to detect your code language. According to the readme in their git you need to create a .gitattributes if you don't have one and write in it the files/types you're matching to a language

So basically put in your .gitattributes

*.h linguist-language=C
like image 125
aram Avatar answered Sep 22 '25 12:09

aram