Git aliases的應(yīng)用可以幫助我們更簡便的用git語句進行版本控制靠闭。這里有兩種方式設(shè)置git aliases,其中一種安裝framework來進行配置疮丛,另一種為修改config文件進行自主配置步清。
oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh)
"Oh My Zsh is an open source, community-driven framework for managing your zsh configuration."[1]
安裝它會主動配置git aliases管钳,配置文件如下:https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh
.gitconfig
.gitconfig是git的配置文件,比如git的用戶名玲献,密碼等也存在這個文檔殉疼,存檔路徑在MAC上為
~/.gitconfig
有兩種通過修改aliases的途徑,第一種直接編輯.gitconfig青自。在.gitconfig中加入如下語句
[alias]
st = status
ci = commit -v
第二種通過command直接進行添加株依,git官方文檔如下:https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
$ git config --global alias.co checkout
常用 git aliases from on-my-zsh[1]
Command | Alias |
---|---|
git add | ga |
git branch | gb |
git branch -D | gbD |
git checkout -b | gcb |
git checkout master | gcm |
git checkout develop | gcd |
git commit -m | gcmsg |
git checkout | gco |
git diff | gd |
git fetch | gf |
git pull | gl |
git merge | gm |
git push | gp |
git rebase | grb |
git reset | grh |
git status | gst |
references
[1] oh-my-zsh github repository, https://github.com/robbyrussell/oh-my-zsh