配置本地用户和邮箱
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中文乱码问题
解决办法:在git/git-completion.bash中增加一行:
alias ls='ls --show-control-chars --color=auto'
解决办法:修改git/inputrc中对应的行:
set output-meta on
set convert-meta off
使用git-bash查看git log,中文正常输出。如果乱码设置环境变量:LESSCHARSET=utf-8
解决办法:在git/profile中增加一行:
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