一、设置别名
定义别名:git config --global alias.【别名】 【选项】
查看使用的别名:git config --list |grep alias
查询Log显示颜色对比: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"
取消别名:git config --global --unset alias 【定义的别名】
1:定义checkout和branch的别名分别为:co、br
[root@ghs gitroot]#
git config --global alias.co checkout
[root@ghs gitroot]#
git config --global alias.br branch
使用定义的别名git br查看分支
[root@ghs gitroot]#
git br
master
* yunche
使用定义的别名git co切换分支
[root@ghs gitroot]#
git co master
Switched to branch 'master'
[root@ghs gitroot]#
git br
* master
yunche
2:查看列出使用的别名
[root@ghs gitroot]#
git config --list|grep alias
alias.co=checkout
alias.br=branch
也可在/root/.gitconfig文件里查看所定义的别名
[root@ghs gitroot]#
cat /root/.gitconfig
[user]
name = ghs
email = ghs@ghs.com
[alias]
co =checkout
br = branch
3:取消co=checkout的别名
[root@ghs gitroot]#
git config --global --unset alias.co
查看使用的别名中已经没有
alias.co=checkout
[root@ghs gitroot]#
git config --list|grep alias
alias.br=branch