git.plugin.zsh 3.12 KB
Newer Older
1
2
# Aliases
alias g='git'
3
compdef g=git
4
alias gst='git status'
5
compdef _git gst=git-status
Jordan MacDonald's avatar
Jordan MacDonald committed
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
Hakan Ensari's avatar
Hakan Ensari committed
25
alias gco='git checkout'
26
compdef _git gco=git-checkout
27
alias gcm='git checkout master'
mapc's avatar
mapc committed
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
Sven Lito's avatar
Sven Lito committed
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
Steven G. Harms's avatar
Steven G. Harms committed
55
56
alias glo='git log --oneline'
compdef _git glo=git-log
57
58
alias gss='git status -s'
compdef _git gss=git-status
59
60
alias ga='git add'
compdef _git ga=git-add
Dan Shearmur's avatar
Dan Shearmur committed
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'
Marcus Müller's avatar
Marcus Müller committed
66
alias gf='git ls-files | grep'
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

Sven Lito's avatar
Sven Lito committed
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/}
}

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

Hakan Ensari's avatar
Typo    
Hakan Ensari committed
95
# these aliases take advantage of the previous function
96
alias ggpull='git pull origin $(current_branch)'
97
compdef ggpull=git
98
99
alias ggpur='git pull --rebase origin $(current_branch)'
compdef ggpur=git
100
alias ggpush='git push origin $(current_branch)'
101
compdef ggpush=git
Hakan Ensari's avatar
Typo    
Hakan Ensari committed
102
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
pomaxa's avatar
pomaxa committed
103
compdef ggpnp=git
Steven G. Harms's avatar
Steven G. Harms committed
104
105
106
107
108
109
110
111
112

# 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