首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Mac OS X上的Git和Umlaut问题

Mac OS X上的Git和Umlaut问题
EN

Stack Overflow用户
提问于 2011-04-07 21:27:59
回答 5查看 17.3K关注 0票数 73

今天我在Mac和OS上发现了一个Git的bug。

例如,我将提交一个名称为überschrift.txt的文件,其开头为德语特殊字符µ。在命令git status中,我得到以下输出。

代码语言:javascript
复制
Users-iMac: user$ git status

On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   "U\314\210berschrift.txt"
nothing added to commit but untracked files present (use "git add" to track)

似乎Git 1.7.2在Mac和OS上的德语特殊字符有问题。有没有解决方案让Git读取正确的文件名?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2013-03-22 01:06:38

在mac上启用core.precomposeunicode

代码语言:javascript
复制
git config --global core.precomposeunicode true

要实现这一点,您需要至少安装Git 1.8.2。

Mountain Lion的发行版是1.7.5。要获得更新的git,可以使用git-osx-installerhomebrew (需要Xcode)。

就这样。

票数 89
EN

Stack Overflow用户

发布于 2016-12-21 01:44:44

以下放入~/.gitconfig中的内容在10.12.1 Sierra上适用于UTF-8名称:

代码语言:javascript
复制
precomposeunicode = true
quotepath = false

需要第一个选项,这样git才能“理解”UTF-8,第二个选项才不会转义字符。

票数 10
EN

Stack Overflow用户

发布于 2011-09-06 23:04:32

要使git add file在Mac上与文件名中的变音一起工作,可以使用iconv将文件路径字符串从合成的UTF-8转换为规范分解的UTF-8。

代码语言:javascript
复制
# test case

mkdir testproject
cd testproject

git --version    # git version 1.7.6.1
locale charmap   # UTF-8

git init
file=$'\303\234berschrift.txt'    # composed UTF-8 (Linux-compatible)
touch "$file"
echo 'Hello, world!' > "$file"

# convert composed into canonically decomposed UTF-8
# cf. http://codesnippets.joyent.com/posts/show/12251
# printf '%s' "$file" | iconv -f utf-8 -t utf-8-mac | LC_ALL=C vis -fotc 
#git add "$file"
git add "$(printf '%s' "$file" | iconv -f utf-8 -t utf-8-mac)"  

git commit -a -m 'This is my commit message!'
git show
git status
git ls-files '*'
git ls-files -z '*' | tr '\0' '\n'

touch $'caf\303\251 1' $'caf\303\251 2' $'caf\303\251 3'
git ls-files --other '*'
git ls-files -z --other '*' | tr '\0' '\n'
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5581857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档