git-設置別名


一、設置別名
 
定義別名: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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM