d-mac
d-mac

Reputation: 122

What is the appropriate character encoding for a git repo?

Specifically what encoding to use if the repo has both code and docs? Any .md or .htm files are saved as UTF-8, but code is cp1252 (my compiler doesn't like the 3-byte BOM which Windows adds to UTF-8 files).

As seen in Git GUI tool (Edit -> Options...):

As seen in Git GUI tool

Frankly, does it even matter what setting I choose?

My system is Windows 8.1, and the system encoding is cp1252

Upvotes: 5

Views: 15621

Answers (1)

phd
phd

Reputation: 94397

The setting in git GUI only sets the default encoding. Real encoding should be set via .gitattributes. For example:

echo '*.html encoding=utf-8' >> .gitattributes
echo '*.c encoding=cp1252' >> .gitattributes

PS. What editor do you use that you cannot configure BOM in it? I recommend to disable BOM and use one encoding for all text files.

Upvotes: 9

Related Questions