git.plugin.zsh 2.7 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
alias gd='git diff'
13
gdv() { git diff -w "$@" | view - }
14
compdef _git gdv=git-diff
15
alias gc='git commit -v'
16
compdef _git gc=git-commit
17
alias gca='git commit -v -a'
18
compdef _git gca=git-commit
H
Hakan Ensari 已提交
19
alias gco='git checkout'
20
compdef _git gco=git-checkout
21
alias gcm='git checkout master'
M
mapc 已提交
22 23 24 25 26 27 28 29 30 31 32 33
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
34
alias gb='git branch'
35
compdef _git gb=git-branch
36
alias gba='git branch -a'
37
compdef _git gba=git-branch
38
alias gcount='git shortlog -sn'
39
compdef gcount=git
40
alias gcl='git config --list'
41
alias gcp='git cherry-pick'
42
compdef _git gcp=git-cherry-pick
43
alias glg='git log --stat --max-count=5'
44
compdef _git glg=git-log
S
Sven Lito 已提交
45 46
alias glgg='git log --graph --max-count=5'
compdef _git glgg=git-log
47
alias glgga='git log --graph --decorate --all'
48
compdef _git glgga=git-log
M
Mark Szymanski 已提交
49 50
alias gss='git status -s'
compdef _git gss=git-status
51 52
alias ga='git add'
compdef _git ga=git-add
D
Dan Shearmur 已提交
53 54
alias gm='git merge'
compdef _git gm=git-merge
55
alias grh='git reset HEAD'
56
alias grhh='git reset HEAD --hard'
57
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
M
Marcus Müller 已提交
58
alias gf='git ls-files | grep'
A
Alexander Surma 已提交
59
alias gpoat='git push origin --all && git push origin --tags'
60

61 62 63 64
# Will cd into the top of the current repository
# or submodule.
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'

65 66
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
67
compdef git-svn-dcommit-push=git
68

S
Sven Lito 已提交
69 70
alias gsr='git svn rebase'
alias gsd='git svn dcommit'
71 72 73 74 75
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
76 77
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
78 79 80
  echo ${ref#refs/heads/}
}

P
pomaxa 已提交
81
function current_repository() {
82 83
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
P
pomaxa 已提交
84 85 86
  echo $(git remote -v | cut -d':' -f 2)
}

H
Typo  
Hakan Ensari 已提交
87
# these aliases take advantage of the previous function
88
alias ggpull='git pull origin $(current_branch)'
89
compdef ggpull=git
90
alias ggpush='git push origin $(current_branch)'
91
compdef ggpush=git
H
Typo  
Hakan Ensari 已提交
92
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
P
pomaxa 已提交
93
compdef ggpnp=git