Git配置中文,有两种方式
一、命令行指令
通过以下指令,可以配置:
git config --global core.quotepath false
git config --global i18n.logoutputencoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.commit.clean utf-8
git config --global i18n.branch.encoding utf-8
二、修改全局Git配置文件
先打开配置文件:
# 打开全局Git配置文件
git config --global --edit
按下 [ i ] 键修改:
[core]
excludesfile = xxxxxx
autocrlf = input
quotepath = false
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[user]
name = 你单排吧
email = xxxx
[commit]
template = xxxxx
[init]
defaultBranch = main
[safe]
directory = /opt/homebrew
[pull]
rebase = false
[i18n]
logoutputencoding = utf-8
[i18n "commit"]
encoding = utf-8
clean = utf-8
encoding = utf-8
以上代码中,看到utf-8的都需要加上。另外,[core]中的quotepath = false也补上。修改完成后,依次按:esc - shift+z+z 退出编辑。