Daniel Santos
Daniel Santos

Reputation: 15778

Can Git mess up file encodings?

Is it possible that Git can mess up the file encoding? For instance, might a text file with some non-standard English characters like ç, ã, é (or even ひらがな) be damaged at pull or push?

Upvotes: 1

Views: 176

Answers (1)

TRiG
TRiG

Reputation: 10643

Git on Windows can be set to automatically change line endings on pull and push. In other words, it will always commit and push Unix line endings, but the files it creates will have Windows line endings. This could potentially cause problems with binary files which Git incorrectly detects as text files. It could also theoretically cause problems with actual text files, but this is very very unlikely, as the vast vast majority of text encodings start with ASCII and then add stuff on, which means that the bytes for CR and LF line endings are the same in almost all text encodings. (Well known exceptions, which I imagine Git accounts for, are UFT-16 and UTF-32. There are also some less well known exceptions, such as BinarySignWriting, which doesn’t contain ASCII characters at all.)

Upvotes: 1

Related Questions