合理地配置 Git 可以提高开发效率,下面是本人常用的 Git 设置。
1.快速设置
vi ~/.gitconfig
[alias]
pl = pull
ps = push
ci = commit
co = checkout
st = status
br = branch
cl = clone
unstage = reset HEAD --
last = log -1 HEAD
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset %ae' --abbrev-commit
name163 = config user.name echo
email163 = config user.email echo940811@163.com
namebili = config user.name wucongyou
emailbili = config user.email wucongyou@bilibili.com
conf = config -l
name = config user.name
email = config user.email
附:常用别名
# the most common alias for git
$ git config --global alias.ci commit
$ git config --global alias.co checkout
$ git config --global alias.st status
$ git config --global alias.br branch
$ git config --global alias.conf 'config -l'
# other
$ git config --global alias.unstage 'reset HEAD --'
$ git config --global alias.last 'log -1 HEAD'
$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# advanced
git config --global alias.name 'config user.name'
git config --global alias.email 'config user.email'
# username and email use in github
$ git config --global alias.name163 'config user.name echo'
$ git config --global alias.email163 'config user.email echo940811@163.com'
# username and email use in gitlab
$ git config --global alias.nameCompany 'config user.name wucongyou'
$ git config --global alias.emailCompany 'config user.email wucongyou@yourcompany.com'
2.更改 Git 的语言设定为英文(在Ubuntu下)
vi ~/.bashrc,添加如下行
alias git='LANG=en_US git'