git.plugin.zsh 4.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 9
alias gdc='git diff --cached'
compdef _git gdc=git-diff
10
alias gl='git pull'
11
compdef _git gl=git-pull
12
alias gup='git pull --rebase'
13
compdef _git gup=git-fetch
14
alias gp='git push'
15
compdef _git gp=git-push
16
alias gd='git diff'
17
gdv() { git diff -w "$@" | view - }
18
compdef _git gdv=git-diff
19
alias gc='git commit -v'
20
compdef _git gc=git-commit
21 22
alias gc!='git commit -v --amend'
compdef _git gc!=git-commit
23
alias gca='git commit -v -a'
24 25 26
compdef _git gc=git-commit
alias gca!='git commit -v -a --amend'
compdef _git gca!=git-commit
27
alias gcmsg='git commit -m'
28
compdef _git gcmsg=git-commit
H
Hakan Ensari 已提交
29
alias gco='git checkout'
30
compdef _git gco=git-checkout
31
alias gcm='git checkout master'
M
mapc 已提交
32 33 34 35 36 37 38 39 40 41 42 43
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 已提交
44 45 46 47 48 49
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
50
alias gb='git branch'
51
compdef _git gb=git-branch
52
alias gba='git branch -a'
53
compdef _git gba=git-branch
54
alias gcount='git shortlog -sn'
55
compdef gcount=git
56
alias gcl='git config --list'
57
alias gcp='git cherry-pick'
58
compdef _git gcp=git-cherry-pick
Y
yleo77 已提交
59
alias glg='git log --stat --max-count=10'
60
compdef _git glg=git-log
Y
yleo77 已提交
61
alias glgg='git log --graph --max-count=10'
S
Sven Lito 已提交
62
compdef _git glgg=git-log
63
alias glgga='git log --graph --decorate --all'
64
compdef _git glgga=git-log
E
Emanuele Zattin 已提交
65
alias glo='git log --oneline --decorate --color'
S
Steven G. Harms 已提交
66
compdef _git glo=git-log
E
Emanuele Zattin 已提交
67 68
alias glog='git log --oneline --decorate --color --graph'
compdef _git glog=git-log
M
Mark Szymanski 已提交
69 70
alias gss='git status -s'
compdef _git gss=git-status
71 72
alias ga='git add'
compdef _git ga=git-add
D
Dan Shearmur 已提交
73 74
alias gm='git merge'
compdef _git gm=git-merge
75
alias grh='git reset HEAD'
76
alias grhh='git reset HEAD --hard'
A
Ayush Samantroy 已提交
77
alias gclean='git reset --hard && git clean -dfx'
78
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
Y
yleo77 已提交
79 80 81 82

#remove the gf alias
#alias gf='git ls-files | grep'

A
Alexander Surma 已提交
83
alias gpoat='git push origin --all && git push origin --tags'
G
Gaetan Semet 已提交
84 85 86 87 88 89
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'
90

O
Okura Masafumi 已提交
91
alias gsts='git stash show --text'
92 93 94
alias gsta='git stash'
alias gstp='git stash pop'
alias gstd='git stash drop'
95

96 97 98 99
# Will cd into the top of the current repository
# or submodule.
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'

100 101
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
102
compdef git-svn-dcommit-push=git
103

S
Sven Lito 已提交
104 105
alias gsr='git svn rebase'
alias gsd='git svn dcommit'
106 107 108 109 110
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
111 112
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
113 114 115
  echo ${ref#refs/heads/}
}

P
pomaxa 已提交
116
function current_repository() {
117 118
  ref=$(git symbolic-ref HEAD 2> /dev/null) || \
  ref=$(git rev-parse --short HEAD 2> /dev/null) || return
P
pomaxa 已提交
119 120 121
  echo $(git remote -v | cut -d':' -f 2)
}

H
Typo  
Hakan Ensari 已提交
122
# these aliases take advantage of the previous function
123
alias ggpull='git pull origin $(current_branch)'
124
compdef ggpull=git
125 126
alias ggpur='git pull --rebase origin $(current_branch)'
compdef ggpur=git
127
alias ggpush='git push origin $(current_branch)'
128
compdef ggpush=git
H
Typo  
Hakan Ensari 已提交
129
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
P
pomaxa 已提交
130
compdef ggpnp=git
S
Steven G. Harms 已提交
131 132 133 134 135 136 137 138 139

# 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
140 141 142 143 144 145 146

# Work In Progress (wip)
# These features allow to pause a branch development and switch to another one (wip)
# When you want to go back to work, just unwip it
#
# This function return a warning if the current branch is a wip
function work_in_progress() {
S
Sam O 已提交
147
  if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
148 149 150 151
    echo "WIP!!"
  fi
}
# these alias commit and uncomit wip branches
152
alias gwip='git add -A; git ls-files --deleted -z | xargs -r0 git rm; git commit -m "--wip--"'
S
Sam O 已提交
153
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
O
onemouth 已提交
154 155 156 157 158 159 160 161 162

# these alias ignore changes to file
alias gignore='git update-index --assume-unchanged'
alias gunignore='git update-index --no-assume-unchanged'
# list temporarily ignored files
alias gignored='git ls-files -v | grep "^[[:lower:]]"'