MXOXW

Life always finds a way.

2016-05-24面试

| Comments

  1. 对系统架构的理解;
  2. 项目中疑难问题的解决过程;
  3. 职业规划;
  4. 项目的参与度;

git中文显示问题

| Comments

Git的本地化做得并不完善,命令的输出及命令的帮助还只能输出英文。目前中文用户最关心的问题是:是否可以在提交说明中使用中文?是否可以使用中文文件名或目录名?是否可以使用中文来命名分支或里程碑?简单地说,可以在提交说明中使用中文,但是需要对Git进行设置。至于用中文来命名文件,目录和引用,只有在使用UTF-8字符集的环境下(Linux,Mac OS X,Windows下的Cygwin)才可以,否则应尽量避免使用。

UTF-8字符集
Linux平台的中文用户一般会使用UTF-8字符集,Git在UTF-8字符集下可以工作得非常好:
在提交时,可以在提交说明中输入中文。
显示提交历史,能够正常显示提交说明中的中文字符。
可以添加名称为中文的文件,并可以在同样使用UTF-8字符集的Linux环境中克隆和检出。
可以创建带有中文字符的里程碑名称。
但是,在默认设置下,中文文件名在工作区状态输出,查看历史更改概要,以及在补丁文件中,文件名的中文不能正确地显示,而是显示为八进制的字符编码,示例如下:

1
2
3
4
$ git status -s
?? "\350\257\264\346\230\216.txt\n
$ printf "\350\257\264\346\230\216.txt\n"
说明.txt

通过将Git配置变量 core.quotepath 设置为false,就可以解决中文文件名称在这些Git命令输出中的显示问题,示例:

1
2
3
$ git config --global core.quotepath false
$ git status -s
?? 说明.txt

GBK字符集

如果Linux平台采用非UTF-8的字符集,例如用zh_CN.GBK字符集编码,就要另外再做些工作了。
将显示提交说明所使用的字符集设置为gbk,这样使用 git log 查看提交说明时才能够正确显示其中的中文:

1
$ git config --global i18n.logOutputEncodiing gbk

设置录入提交说明时所使用的字符集,以便在commit对象中正确标注字符集。Git在提交时并不会对提交说明进行从GBK字符集到UTF-8的转换,但是可以在提交说明中标所使用的字符集,因此在非UTF-8字符集的平台中录入中文时需要用下面的指令设置录入提交说明的字符集,以便在commit对象中嵌入正确的编码说明。

1
$ git config --global i18n.commitEncoding gbk

参考:http://www.open-open.com/lib/view/open1418264702277.html

git颜色配置

| Comments

git config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[user]
email =
name =
[core]
editor = 'D:\\Program Files\\SublimeText\\subl.exe' -w
longpaths = true
quotepath = false
excludesfile = "D:\\Documents\\My Document\\BackUp\\.gitignore"
[alias]
st = status
sh = show
pl = pull
pu = push
ft = fetch
ss = stash
cm = commit
br = branch
cl = clone
co = checkout
df = diff
dfl = diff --stat
dft = difftool
dfr = diff origin master
dfrl = diff origin master --stat
mg = merge
mgt = mergetool
lg = log --color --graph --pretty=format:'%C(magenta)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr) %C(cyan)<%an>%Creset' --abbrev-commit
last = log -1
[commit]
template = D:\\Documents\\My Document\\BackUp\\.gitmessage.txt
[color]
ui = true
[diff]
tool = bc4
[difftool "bc4"]
cmd = \"D:/Program Files/Beyond Compare 4/BComp.exe\" \"$LOCAL\" \"$REMOTE\"
trustExitCode = true
[merge]
tool = bc4
conflictstyle = diff3
[mergetool "bc4"]
cmd = \"D:/Program Files/Beyond Compare 4/BComp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
trustExitCode = true
[credential]
helper = wincred
[difftool]
prompt = false

bold
dim
ul
blink
reverse

支持的颜色
normal
black
red
green
yellow
blue
magenta
cyan
white