12

在我的 Git 存储库中,重音文件为 éíóúàèìòùãõ_800x600.jpg,但在进行克隆后,我无法拉取,因为文件显示为已修改:

$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"

尽管如此,我还是无法添加、删除、重置或存储文件。

我试过了:

$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"

如何处理转换为 unicode 的重音文件?

4

2 回答 2

14

您需要在 Mac 上将 core.precomposeunicode 选项设置为 true,然后再次克隆存储库。

git config --global core.precomposeunicode true

git config man page中所述,该选项与 Mac OS 中 Unicode 字符的特定分解有关:

此选项仅由 git 的 Mac OS 实现使用。当 core.precomposeunicode=true 时,git 恢复 Mac OS 对文件名的 unicode 分解。这在 Mac OS 和 Linux 或 Windows 之间共享存储库时很有用。(需要 Windows 1.7.10 或更高版本的 Git,或 cygwin 1.7 下的 git)。当为 false 时,文件名由 git 完全透明地处理,这与旧版本的 git 向后兼容。

手册页没有指出的是,此选项对存储库没有追溯影响,它仅在之后克隆的存储库中生效。

参考: Leo Koppelkamm 在“Mac OS X 上的 Git 和变音符号问题”中的回答

于 2013-12-12T18:11:07.293 回答
1

如何在 OS X 上的 Git 中处理文件名中的亚洲字符

于 2012-08-15T12:38:32.267 回答