Last Updated: August 28, 2018
· 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.

1 Response
Add your response


All I seem to have lost now are my storyboards, translations and 2 viewcontroller files, a LOT better than losing https://www.applock.ooo/ everything. 4 hours into fixing https://www.7zip.vip/ it I'm almost done, I'll definitely not wait with fixing GIT next time if an error occurs


2 months ago ·