Read more

Git & Mac: Working with Unicode filenames

Dominik Schöler
August 21, 2013Software engineer at makandra GmbH

I had some problems with Git and the file spec/fixtures/ČeskýÁČĎÉĚÍŇÓŘŠŤÚŮÝŽáčďéěíňóřšťúůýž. After pulling the latest commits, it would show that file as untracked, but adding and committing it would throw error: pathspec 'check in unicode fixture file once again' did not match any file(s) known to git.

Solution

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

Install Git version > 1.8.2 using homebrew Show archive.org snapshot and set

git config --global core.precomposeunicode true

Done.

Reason

According to the linked Stackoverflow post ...

... the cause is the different implementation of how the filesystem stores the file name.
In Unicode, Ü can be represented in two ways, one is by Ü alone, the other is by U + "combining umlaut character". A Unicode string can contain both forms, but as it's confusing to have both, the file system normalizes the unicode string by setting every umlauted-U to Ü, or U + "combining umlaut character".

Linux uses the former method, called Normal-Form-Composed (or NFC), and Mac OS X uses the latter method, called Normal-Form-Decomposed (NFD).

Apparently Git doesn't care about this point and simply uses the byte sequence of the filename, which leads to the problem you're having.

Dominik 08.13: Currently, checking out branches still does not work for me.

Posted by Dominik Schöler to makandra dev (2013-08-21 11:23)