Last Updated: December 26, 2018
·
5.382K
· siuying

Fix: git recognized Xcode localization file as binaries

Sometime, a file in git cannot be view or diff, it is labeled "binary":

It look like git treat a text file as binary. To fix this, create a file named ".gitattributes" under project folder, and add following line inside:

 *.strings text diff

After that, all *.strings file will be treated as text and can be diffed.

But that did not solve my problem. When I diff the file, what I get is something scramble:

This is in fact a correct representation of the content: it shows the binaries of the file. When we open this file in Xcode, it can be opened properly.

Turns out, this file is saved as UTF-16. We can make git understand the format by convert the file into UTF-8.

Select "UTF-8" and when it is asked, select "Convert":

When it is done, git will be able to display the diff and work with the file as it should.