Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git 快捷键alias与oh-my-zsh #5

Open
berwin opened this issue Dec 2, 2015 · 5 comments
Open

git 快捷键alias与oh-my-zsh #5

berwin opened this issue Dec 2, 2015 · 5 comments
Assignees
Labels

Comments

@berwin
Copy link
Owner

@berwin berwin commented Dec 2, 2015

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啊~~~

@berwin berwin added the Blog label Dec 2, 2015
@codezyc
Copy link

@codezyc codezyc commented Dec 2, 2015

good

@berwin berwin self-assigned this Dec 14, 2015
@berwin berwin added the Git label Apr 15, 2016
@lymanlai
Copy link

@lymanlai lymanlai commented Jul 25, 2016

我直接更暴力

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

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

@Zenser
Copy link

@Zenser Zenser commented Sep 23, 2016

可以的

@baixiaoji
Copy link

@baixiaoji baixiaoji commented Aug 11, 2017

不错

@GoldenRaven
Copy link

@GoldenRaven GoldenRaven commented Mar 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.