如何在Mac OS X上转换为unicode的Git中的文件名中处理带重音符号的字符 [英] How to handle accented characters in file names in Git on Mac OS X converted to unicode

查看:66
本文介绍了如何在Mac OS X上转换为unicode的Git中的文件名中处理带重音符号的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我尝试过:

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

How handle with accented files converted to unicode?

推荐答案

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

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

git config --global core.precomposeunicode true

git config手册页中所述

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

此选项仅由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的较早版本向后兼容.

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.

参考: Leo Koppelkamm在"Mac OS X上的Git和Umlaut问题"中的答案

这篇关于如何在Mac OS X上转换为unicode的Git中的文件名中处理带重音符号的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆