git.plugin.zsh 4.5 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
S
Steven G. Harms 已提交
65 66
alias glo='git log --oneline'
compdef _git glo=git-log
M
Mark Szymanski 已提交
67 68
alias gss='git status -s'
compdef _git gss=git-status
69 70
alias ga='git add'
compdef _git ga=git-add
D
Dan Shearmur 已提交
71 72
alias gm='git merge'
compdef _git gm=git-merge
73
alias grh='git reset HEAD'
74
alias grhh='git reset HEAD --hard'
A
Ayush Samantroy 已提交
75
alias gclean='git reset --hard && git clean -dfx'
76
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
Y
yleo77 已提交
77 78 79 80

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

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

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

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

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

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

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

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

# 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
138 139 140 141 142 143 144

# 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 已提交
145
  if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
146 147 148 149
    echo "WIP!!"
  fi
}
# these alias commit and uncomit wip branches
S
Sam O 已提交
150
alias gwip='git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m "--wip--"'
S
Sam O 已提交
151
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
O
onemouth 已提交
152 153 154 155 156 157 158 159 160

# 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:]]"'