Git命令输出显示特殊字符 [英] Git command output shows special characters
问题描述
在过去的几天中,我们看到执行Git命令的行为很奇怪.
For the past few days, we are seeing a strange behavior on executing Git commands.
已执行命令:git show 08fcf54adc7bbb75a54b14625fdeea7608d44a23> sample.patch
Command executed: git show 08fcf54adc7bbb75a54b14625fdeea7608d44a23 > sample.patch
在通过 vi编辑器打开文件sample.patch时,我们看到了很多特殊字符;例如:一个示例输出文件如下所示:
On opening the file sample.patch through vi editor, we are seeing a lot of special characters; a sample output file looks like:
^[[33mcommit 08fcf54adc7bbb75a54b14625fdeea7608d44a23^[[m
Author: Anshul Gupta <anshul.gupta@lnttechservices.com>
Date: Wed Nov 26 23:27:20 2014 +0400
Remove redundant logs from EPD driver
Change-Id: I078584ddd7a58da1052a8d46fd59af722e11136b
^[[1mdiff --git a/drivers/video/s1d13522/s1d13522fb.c b/drivers/video/s1d13522/s1d13522fb.c^[[m
^[[1mindex ca568ad..5e67de6 100644^[[m
^[[1m--- a/drivers/video/s1d13522/s1d13522fb.c^[[m
^[[1m+++ b/drivers/video/s1d13522/s1d13522fb.c^[[m
^[[36m@@ -1099,7 +1099,7 @@^[[m ^[[mstatic void s1d13522fb_display_init_wq(struct work_struct *work)^[[m
注意1::仅对于一个特定用户(在Ubuntu服务器上)会看到此问题.因此,可能看起来像是Git或vi编辑器的配置问题.
Note1: The issue is seen only for one particular user(on Ubuntu server). So possibly it looks like the configuration issue with Git or maybe vi editor.
注意2:正常的文件重定向似乎正常.例如abc abc> xyz,内容正确复制,没有特殊字符
Note2: The normal file redirection seems to be working fine. Example cat abc > xyz, the contents are copied properly with no special characters
任何帮助将不胜感激.
推荐答案
检查Git颜色设置.似乎已为该特定用户将它们设置为 true ,但是您想改用 auto .
Check the Git color settings. It looks like they're set to true for this particular user, but you want to use auto instead.
您看到的字符是终端的颜色代码.设置为 auto 的颜色时,将它们传递到vi时不应该看到它们.
The characters you're seeing are color codes for the terminal. With a color setting of auto, they shouldn't be visible when piping to vi.
在此处查看更详细的问题/答案: https://unix.stackexchange.com/questions/44266/how-to-colorize-output-of-git
Check out a more detailed question/answer here: https://unix.stackexchange.com/questions/44266/how-to-colorize-output-of-git
Git文档: http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Colors-in-Git
默认值为 auto ,因此看起来有问题的用户具有覆盖默认值的本地配置.
The default value is auto, so it looks like the user in question has a local configuration overriding the default values.
这篇关于Git命令输出显示特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!