File cannot be viewed, only downloaded (classed a raw)

Similar to the thread “GitHub doesn’t show my code [view raw]”, my code files cannot be viewed directly and can only be downloaded (they are classed as ‘view raw’)

For instance, here’s one of my files

The file extension is an MQL4 .mqh (very similar to C)
But other Repositories (e.g. this one) have no trouble displaying these types of file directly.

Is there some sort of Repository (or individual file) configuration necessary to get these files recognised? I’ve searched the community, googled but can’t find anything - except this thread I’ve mentioned above.

Thanks

You’ll notice that the repository that you linked to has a .gitattributes file. This file is used to inform git that its defaults might not recognize a file type properly and to override them. I notice that in that .gitattributes file, there is a line to force the file type for .mqh to text (as opposed to binary), as well as force the character set to CP1252 for all files in the directory you linked to. (git doesn’t do well when you’re using a character set other than UTF-8, which might be why those files are being recognized as binary instead of text.)

If you add a .gitattributes file to your repository and instruct git on how to properly interpret the contents of your files, then you should be able to make things appear the way you want.

I hope that helps!

1 Like

Thank you, Thank you!
Yeah, you were right. Not only did the .gitattributes supply the configuration I was looking for (i.e. how to handle my file extensions) but another thank you for bringing my attention to the file encodings. (A couple of my files are indeed UTF-16! Tested with a new ANSI encoded file and viewing worked exactly as I expected. No matter, I’ll copy the contents over to a new file with simple, ANSI encoding)

=o)

1 Like