git.plugin.zsh 3.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
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
H
Hakan Ensari 已提交
25
alias gco='git checkout'
26
compdef _git gco=git-checkout
27
alias gcm='git checkout master'
M
mapc 已提交
28 29 30 31 32 33 34 35 36 37 38 39
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
40
alias gb='git branch'
41
compdef _git gb=git-branch
42
alias gba='git branch -a'
43
compdef _git gba=git-branch
44
alias gcount='git shortlog -sn'
45
compdef gcount=git
46
alias gcl='git config --list'
47
alias gcp='git cherry-pick'
48
compdef _git gcp=git-cherry-pick
49
alias glg='git log --stat --max-count=5'
50
compdef _git glg=git-log
S
Sven Lito 已提交
51 52
alias glgg='git log --graph --max-count=5'
compdef _git glgg=git-log
53
alias glgga='git log --graph --decorate --all'
54
compdef _git glgga=git-log
S
Steven G. Harms 已提交
55 56
alias glo='git log --oneline'
compdef _git glo=git-log
M
Mark Szymanski 已提交
57 58
alias gss='git status -s'
compdef _git gss=git-status
59 60
alias ga='git add'
compdef _git ga=git-add
D
Dan Shearmur 已提交
61 62
alias gm='git merge'
compdef _git gm=git-merge
63
alias grh='git reset HEAD'
64
alias grhh='git reset HEAD --hard'
65
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
M
Marcus Müller 已提交
66
alias gf='git ls-files | grep'
A
Alexander Surma 已提交
67
alias gpoat='git push origin --all && git push origin --tags'
68

69 70 71 72
# Will cd into the top of the current repository
# or submodule.
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'

73 74
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
75
compdef git-svn-dcommit-push=git
76

S
Sven Lito 已提交
77 78
alias gsr='git svn rebase'
alias gsd='git svn dcommit'
79 80 81 82 83
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
84 85
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
86 87 88
  echo ${ref#refs/heads/}
}

P
pomaxa 已提交
89
function current_repository() {
90 91
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
P
pomaxa 已提交
92 93 94
  echo $(git remote -v | cut -d':' -f 2)
}

H
Typo  
Hakan Ensari 已提交
95
# these aliases take advantage of the previous function
96
alias ggpull='git pull origin $(current_branch)'
97
compdef ggpull=git
98
alias ggpush='git push origin $(current_branch)'
99
compdef ggpush=git
H
Typo  
Hakan Ensari 已提交
100
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
P
pomaxa 已提交
101
compdef ggpnp=git
S
Steven G. Harms 已提交
102 103 104 105 106 107 108 109 110

# 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