why does git treat some cpp files as binary?
Try adding the following line to your $repo/.git/info/attributes
:
*.cpp crlf diff
You can specify it in gitattributes per-repo, per-user and per-system.
Basic check-list
• Do you actually have CRLF or LF line endings in your file?
Yes, CRLF — set core.autocrlf
to true (at least for this repo).
• Does the file contain funny non-ASCII characters: umlauts, diacritics, emoji, kanji, copyright sigil ©, invisible esoteric spaces, etc?..
If yes, better ensure that all the stuff is encoded in UTF-8. Fuzzing with surrogate pairs isn't fun.
• Does the file content start with UTF-8 BOM?
Wipe it now, it makes no sense.
• Does the file content start with UTF16 BOM?
Too bad; I've got no good advice for you at this point; sorry. Contact your system vendor.
It is treating some files as binary, because they have wrong file encoding. It should work ok, if you convert those files to UTF-8 (or to the same encoding that in normal files). To change file encoding use notepad++ or any another way.