git.plugin.zsh 2.0 KB
Newer Older
1 2
# Aliases
alias g='git'
3
compdef g=git
4
alias gst='git status'
5
compdef _git gst=git-status
6
alias gl='git pull'
7
compdef _git gl=git-pull
8
alias gup='git pull --rebase'
9
compdef _git gup=git-fetch
10
alias gp='git push'
11
compdef _git gp=git-push
12
gdv() { git diff -w "$@" | view - }
13
compdef _git gdv=git-diff
14
alias gc='git commit -v'
15
compdef _git gc=git-commit
16
alias gca='git commit -v -a'
17
compdef _git gca=git-commit
H
Hakan Ensari 已提交
18
alias gco='git checkout'
19
compdef _git gco=git-checkout
20
alias gcm='git checkout master'
21
alias gb='git branch'
22
compdef _git gb=git-branch
23
alias gba='git branch -a'
24
compdef _git gba=git-branch
25
alias gcount='git shortlog -sn'
26
compdef gcount=git
27
alias gcp='git cherry-pick'
28
compdef _git gcp=git-cherry-pick
29
alias glg='git log --stat --max-count=5'
30
compdef _git glg=git-log
S
Sven Lito 已提交
31 32
alias glgg='git log --graph --max-count=5'
compdef _git glgg=git-log
M
Mark Szymanski 已提交
33 34
alias gss='git status -s'
compdef _git gss=git-status
35 36
alias ga='git add'
compdef _git ga=git-add
D
Dan Shearmur 已提交
37 38
alias gm='git merge'
compdef _git gm=git-merge
39
alias grh='git reset HEAD'
40
alias grhh='git reset HEAD --hard'
41
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
42

43 44 45 46
# Will cd into the top of the current repository
# or submodule.
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'

47 48
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
49
compdef git-svn-dcommit-push=git
50

S
Sven Lito 已提交
51 52
alias gsr='git svn rebase'
alias gsd='git svn dcommit'
53 54 55 56 57 58 59 60 61
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo ${ref#refs/heads/}
}

P
pomaxa 已提交
62 63 64 65 66 67
function current_repository() {

  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  echo $(git remote -v | cut -d':' -f 2)
}

H
Typo  
Hakan Ensari 已提交
68
# these aliases take advantage of the previous function
69
alias ggpull='git pull origin $(current_branch)'
70
compdef ggpull=git
71
alias ggpush='git push origin $(current_branch)'
72
compdef ggpush=git
H
Typo  
Hakan Ensari 已提交
73
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
P
pomaxa 已提交
74
compdef ggpnp=git