Git aliases的应用可以帮助我们更简便的用git语句进行版本控制。这里有两种方式设置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
网友评论