berwin / Blog

记录成长的过程

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git 快捷键alias与oh-my-zsh

berwin opened this issue · comments

git的快捷键 alias,加 oh-my-zsh应该是使用中比较实用的小技巧

在实际应用中,一遍一遍输入git status,git status,git commit -m 'xx'什么的确实挺繁琐,于是配置alias可以简化成 gst === git status,gcmsg 'xxx' === git commit -m 'xxx',gp === git push等等。。

大概是这样配置的

  • alias gst='git status'
  • alias gp='git push'
  • alias gp='git push'

而且还发现oh-my-zsh默认用的插件是git,查看oh-my-zsh的config

cat ~/.zshrc

其中有一条配置是

plugins=(git)

那么刨根问底拦不住,看看git插件的配置

cat ~/.oh-my-zsh/plugins/git/git.plugin.zsh

发现是一堆alias

alias g='git'

alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'

alias gb='git branch'
alias gba='git branch -a'
alias gbda='git branch --merged | command grep -vE "^(\*|\s*master\s*$)" | command xargs -n 1 git branch -d'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsr='git bisect reset'
alias gbss='git bisect start'

既然oh-my-zsh已经配置好了。。。那我们就可以直接使用了。。。

ga . && gcmsg 'update' && gp

比较下之前的用法

git add . && git commit -m 'update' && git push

简直爽的一bi啊~~~

good

我直接更暴力

gac(){
   git add --all && git commit -m "$*"
}
alias gac=gac

就是后面参数不要输入双引号,应该有更好的方式。。

可以的

不错

commented

我通常只在oh-my-zsh里进行一些简单操作,更复杂的操作在Emacs magit插件中更方便。