Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle accented characters in file names in Git on Mac OS X converted to unicode

Tags:

git

macos

unicode

In my Git repository, has accented files as éíóúàèìòùãõ_800x600.jpg, but after making clone, I can not do pull, because the file appears as modified:

$git clone [...]
done

$git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   "a\314\201e\314\201i\314\201o\314\201u\314\201a\314\200e\314\200i\314\200o\314\200u\314\200a\314\203o\314\203_800x600.jpg"

Still, I can't add, remove, reset or stash the file.

I tried:

$git add a\314\201e\314\201i\314\201o\314\201u\314\201a\314\200e\314\200i\314\200o\314\200u\314\200a\314\203o\314\203_800x600.jpg
fatal: pathspec 'a314201e314201i314201o314201u314201a314200e314200i314200o314200u314200a314203o314203_800x600.jpg' did not match any files

$git stash
No local changes to save

$git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   "a\314\201e\314\201i\314\201o\314\201u\314\201a\314\200e\314\200i\314\200o\314\200u\314\200a\314\203o\314\203_800x600.jpg"

How handle with accented files converted to unicode?

like image 834
Shankar Cabus Avatar asked Aug 15 '12 11:08

Shankar Cabus


2 Answers

You need to set the core.precomposeunicode option to true on the Mac, and clone the repository again.

git config --global core.precomposeunicode true

As described in git config man page, the option is related to the particular decomposition of Unicode characters in Mac OS:

This option is only used by Mac OS implementation of git. When core.precomposeunicode=true, git reverts the unicode decomposition of filenames done by Mac OS. This is useful when sharing a repository between Mac OS and Linux or Windows. (Git for Windows 1.7.10 or higher is needed, or git under cygwin 1.7). When false, file names are handled fully transparent by git, which is backward compatible with older versions of git.

What the man page does not indicate, is that this option has no retroactive effect on a repository, it only takes effect in repositories cloned afterwards.

Reference: Answer by Leo Koppelkamm in "Git and the Umlaut problem on Mac OS X"

like image 55
Eric Bréchemier Avatar answered Nov 09 '22 04:11

Eric Bréchemier


How to handle Asian characters in file names in Git on OS X

like image 1
Helielson Santos Avatar answered Nov 09 '22 04:11

Helielson Santos