Git第六讲 本地配置Git与中文乱码解决

Git配置与SSHKey设置及解决中文乱码问题
本文介绍了如何配置Git的本地用户和邮箱,使用`git config --global`命令进行设置,并展示了配置列表。同时,讲解了如何创建SSHKey以连接GitHub,以及在遇到中文乱码问题时的解决方法,包括修改Git的相关配置以确保正确显示中文。此外,还提到了Git commit和log的中文输出设置。

配置本地用户和邮箱

git config --global   命名  '值';  可以添加新值
如
    git config --global user.name "你的用户名"
    git config --global user.email "你的邮箱"
git config –list   查看配置列表信息


git config   --global --unset  命名   删除配置值  
如:git config --global --unset core.editor
 git config --global core.editor 'vim'
$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=D:/appach/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
core.quotepath=false
core.editor="C:\\Program Files\\Notepad++\\notepad++.exe" -multiInst -notabbar -nosession -noPlugin
pull.rebase=false
credential.helper=manager
gui.encoding=utf-8
i18n.commitencoding=utf-8
i18n.logoutputencoding=utf-8
svn.pathnameencoding=utf-8
core.quotepath=false
core.editor=vim
gui.encoding=utf-8
i18n.commitencoding=utf-8
i18n.logoutputencoding=utf-8
svn.pathnameencoding=utf-8
user.email=邮箱
user.name=用户名
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.quotepath=false
remote.origin.url=连接的git地址
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

创建SSH Key

由于你的本地 Git 仓库和 GitHub 仓库之间的传输是通过SSH加密的,所以我们需要配置验证信息:
git输入命令

$ ssh-keygen -t rsa -C “用户名”或者邮箱 (连续按三次Enter)

可以在本地用户目录下查看到.ssh文件夹,在该文件夹下存在三个文件

id_rsa.pub 查看此文件,直接复制秘钥
打开GitHub 点击头像->settings->SSH and GPG keys->New SSH key
将id_rsa.pub复制的公钥复制进去
验证是否配置成功:

ssh -T git@github.com

验证时可能让你输入YES。
成功提示 : 如果出现Hi han1202012! You’ve successfully authenticated, but GitHub does not provide shell access. 就说明配置成功, 可以连接上GitHub;

解决GIT中文乱码问题

  • ls不能显示中文目录
解决办法:在git/git-completion.bash中增加一行:

alias ls='ls --show-control-chars --color=auto'
  • git commit不能提交中文注释

解决办法:修改git/inputrc中对应的行:
set output-meta on
set convert-meta off

使用git-bash查看git log,中文正常输出。如果乱码设置环境变量:LESSCHARSET=utf-8

  • git log无法显示中文注释

解决办法:在git/profile中增加一行:

  • git add添加要提交的文件的时候乱码

git config --global core.quotepath false

设置git gui的界面编码
global i18n.commitencoding utf-8

设置git gui的界面编码 
git config --global gui.encoding utf-8

设置 commit log 提交时使用 utf-8 编码,可避免服务器上乱码,同时与linux上的提交保持一致!
 git config --global i18n.commitencoding utf-8
 
 git config --global i18n.logoutputencoding utf-8

另外需要在gui界面设置文本为zh_ch  UTF-8

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员路同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值