git.plugin.zsh 3.6 KB
Newer Older
1 2
# Aliases
alias g='git'
3
compdef g=git
4
alias gst='git status'
5
compdef _git gst=git-status
J
Jordan MacDonald 已提交
6
alias gd='git diff'
7
compdef _git gd=git-diff
8
alias gl='git pull'
9
compdef _git gl=git-pull
10
alias gup='git pull --rebase'
11
compdef _git gup=git-fetch
12
alias gp='git push'
13
compdef _git gp=git-push
14
alias gd='git diff'
15
gdv() { git diff -w "$@" | view - }
16
compdef _git gdv=git-diff
17
alias gc='git commit -v'
18
compdef _git gc=git-commit
19 20
alias gc!='git commit -v --amend'
compdef _git gc!=git-commit
21
alias gca='git commit -v -a'
22 23 24
compdef _git gc=git-commit
alias gca!='git commit -v -a --amend'
compdef _git gca!=git-commit
25
alias gcmsg='git commit -m'
26
compdef _git gcmsg=git-commit
H
Hakan Ensari 已提交
27
alias gco='git checkout'
28
compdef _git gco=git-checkout
29
alias gcm='git checkout master'
M
mapc 已提交
30 31 32 33 34 35 36 37 38 39 40 41
alias gr='git remote'
compdef _git gr=git-remote
alias grv='git remote -v'
compdef _git grv=git-remote
alias grmv='git remote rename'
compdef _git grmv=git-remote
alias grrm='git remote remove'
compdef _git grrm=git-remote
alias grset='git remote set-url'
compdef _git grset=git-remote
alias grup='git remote update'
compdef _git grset=git-remote
G
Gaetan Semet 已提交
42 43 44 45 46 47
alias grbi='git rebase -i'
compdef _git grbi=git-rebase
alias grbc='git rebase --continue'
compdef _git grbc=git-rebase
alias grba='git rebase --abort'
compdef _git grba=git-rebase
48
alias gb='git branch'
49
compdef _git gb=git-branch
50
alias gba='git branch -a'
51
compdef _git gba=git-branch
52
alias gcount='git shortlog -sn'
53
compdef gcount=git
54
alias gcl='git config --list'
55
alias gcp='git cherry-pick'
56
compdef _git gcp=git-cherry-pick
57
alias glg='git log --stat --max-count=5'
58
compdef _git glg=git-log
S
Sven Lito 已提交
59 60
alias glgg='git log --graph --max-count=5'
compdef _git glgg=git-log
61
alias glgga='git log --graph --decorate --all'
62
compdef _git glgga=git-log
S
Steven G. Harms 已提交
63 64
alias glo='git log --oneline'
compdef _git glo=git-log
M
Mark Szymanski 已提交
65 66
alias gss='git status -s'
compdef _git gss=git-status
67 68
alias ga='git add'
compdef _git ga=git-add
D
Dan Shearmur 已提交
69 70
alias gm='git merge'
compdef _git gm=git-merge
71
alias grh='git reset HEAD'
72
alias grhh='git reset HEAD --hard'
A
Ayush Samantroy 已提交
73
alias gclean='git reset --hard && git clean -dfx'
74
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
M
Marcus Müller 已提交
75
alias gf='git ls-files | grep'
A
Alexander Surma 已提交
76
alias gpoat='git push origin --all && git push origin --tags'
G
Gaetan Semet 已提交
77 78 79 80 81 82
alias gmt='git mergetool --no-prompt'
compdef _git gm=git-mergetool

alias gg='git gui citool'
alias gga='git gui citool --amend'
alias gk='gitk --all --branches'
O
Okura Masafumi 已提交
83
alias gsts='git stash show --text'
84

85 86 87 88
# Will cd into the top of the current repository
# or submodule.
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'

89 90
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
91
compdef git-svn-dcommit-push=git
92

S
Sven Lito 已提交
93 94
alias gsr='git svn rebase'
alias gsd='git svn dcommit'
95 96 97 98 99
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
100 101
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
102 103 104
  echo ${ref#refs/heads/}
}

P
pomaxa 已提交
105
function current_repository() {
106 107
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
P
pomaxa 已提交
108 109 110
  echo $(git remote -v | cut -d':' -f 2)
}

H
Typo  
Hakan Ensari 已提交
111
# these aliases take advantage of the previous function
112
alias ggpull='git pull origin $(current_branch)'
113
compdef ggpull=git
114 115
alias ggpur='git pull --rebase origin $(current_branch)'
compdef ggpur=git
116
alias ggpush='git push origin $(current_branch)'
117
compdef ggpush=git
H
Typo  
Hakan Ensari 已提交
118
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
P
pomaxa 已提交
119
compdef ggpnp=git
S
Steven G. Harms 已提交
120 121 122 123 124 125 126 127 128

# Pretty log messages
function _git_log_prettily(){
  if ! [ -z $1 ]; then
    git log --pretty=$1
  fi
}
alias glp="_git_log_prettily"
compdef _git glp=git-log