如何让Git在控制台窗口中正确显示UTF-8编码的路径名? [英] How to make Git properly display UTF-8 encoded pathnames in the console window?

查看:492
本文介绍了如何让Git在控制台窗口中正确显示UTF-8编码的路径名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有UTF-8中的文件名,git处理它们O.K,它会正确创建文件,并且github页也显示它正确。除了它会像下面那样在控制台中显示它。

I have file names in UTF-8, git handles them O.K, it will create files properly and github pages also display it right. Except that it will display it in console like below. Is it possible to make git display UTF-8 encoded characters beyond ASCII 127 in console properly?

git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   .gitignore
#       modified:   editfile.js
#       modified:   "\321\203\321\201\321\202\320\260\320\275\320\276\320\262"
#
no changes added to commit (use "git add" and/or "git commit -a")

UPDATE

有人问我的语言环境,这里是 locale 命令的输出。
$ b

I have been asked about my locale, here is the output of locale command

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=


推荐答案

git一直使用八进制utf8显示,并且一种显示实际名称的方法是使用 printf 在bash shell中。

git has always used octal utf8 display, and one way to show the actual name is by using printf in a bash shell.

根据 printf (并可用于如何在git checkout中使用八进制字符? )。

但是这不会改变命令的输出例如 git status git ls-files
但是,由于Git 1.7.10引入了unicode的支持,因此

But that doesn't change the output of commands like git status or git ls-files. However, since Git 1.7.10 introduced the support of unicode, this wiki page mentions:


默认情况下,git将以引用的八进制格式打印非ASCII文件名,即 \\\
nn\\\
nn ...
这可以通过禁用:



 git config core.quotepath off

或者使用以下所有存储库:

Or for all repositories using:

 git config --global core.quotepath off

保留请注意:

Keep in mind that:


默认控制台字体不支持Unicode。将控制台字体更改为TrueType字体,例如Lucida Console或Consolas。

安装程序可以自动执行此操作,但仅限安装用户。

The default console font does not support Unicode. Change the console font to a TrueType font such as Lucida Console or Consolas.
The setup program can do this automatically, but only for the installing user.

这篇关于如何让Git在控制台窗口中正确显示UTF-8编码的路径名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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