]> git.rmz.io Git - dotfiles.git/blob - zsh/aliases/git.zsh
d487d6167ce2b0292b3f42dc33b72a41abe48050
[dotfiles.git] / zsh / aliases / git.zsh
1 # Aliases
2 alias g='git'
3 compdef g=git
4 alias gst='git status'
5 compdef _git gst=git-status
6 alias gsts='git status -s'
7 compdef _git gsts=git-status
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 alias gdc='git diff --cached'
16 alias gc='git commit -v'
17 compdef _git gc=git-commit
18 alias gcs='git commit -v --squash'
19 compdef _git gcs=git-commit
20 alias gcf='git commit -v --fixup'
21 compdef _git gcf=git-commit
22 alias gca='git commit -v -a'
23 compdef _git gca=git-commit
24 alias gco='git checkout'
25 compdef _git gco=git-checkout
26 alias gcm='git checkout master'
27 alias gs='git stash save'
28 compdef _git gs=git-stash
29 alias gsa='git stash apply'
30 compdef _git gsa=git-stash
31 alias gsp='git stash pop'
32 compdef _git gsp=git-stash
33 alias gsd='git stash drop'
34 compdef _git gsd=git-stash
35 alias gsl='git --no-pager stash list'
36 compdef _git gsl=git-stash
37 alias gss='git stash show --patch'
38 compdef _git gss=git-stash
39 alias gr='git remote'
40 compdef _git gr=git-remote
41 alias grv='git remote -v'
42 compdef _git grv=git-remote
43 alias grmv='git remote rename'
44 compdef _git grmv=git-remote
45 alias grrm='git remote remove'
46 compdef _git grrm=git-remote
47 alias grset='git remote set-url'
48 compdef _git grset=git-remote
49 alias grup='git remote update'
50 compdef _git grset=git-remote
51 alias gb='git branch'
52 compdef _git gb=git-branch
53 alias gba='git branch -a'
54 compdef _git gba=git-branch
55 alias gbm='git branch --merged'
56 alias gbdm='git branch --merged | grep -ve "\*" -e "master" | xargs -n 1 git branch -d'
57 alias gcount='git shortlog -sn'
58 compdef gcount=git
59 alias gcl='git config --list'
60 alias gcp='git cherry-pick'
61 compdef _git gcp=git-cherry-pick
62 alias glg='git --no-pager log --oneline --graph --max-count=20 --decorate'
63 alias glg='git --no-pager log --graph --max-count=20 --pretty=tformat:"%Cblue%cd %C(auto)%h%d %s" --date=short'
64 compdef _git glg=git-log
65 alias glgl='git log --graph --pretty=tformat:"%Cblue%cd %C(auto)%h%d %s" --date=short'
66 compdef _git glgl=git-log
67 alias glgg='git log --stat --graph --max-count=20 --decorate'
68 compdef _git glgg=git-log
69 alias glgga='git log --stat --graph --decorate --all'
70 compdef _git glgga=git-log
71 alias ga='git add'
72 compdef _git ga=git-add
73 alias gm='git merge'
74 compdef _git gm=git-merge
75 alias grh='git reset HEAD'
76 alias grhh='git reset HEAD --hard'
77 alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
78 alias gf='git ls-files | grep'
79 alias gpoat='git push origin --all && git push origin --tags'
80
81 # Will cd into the top of the current repository
82 # or submodule.
83 alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
84
85 # Git and svn mix
86 alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
87 compdef git-svn-dcommit-push=git
88
89 alias gsr='git svn rebase'
90 alias gsd='git svn dcommit'
91 #
92 # Will return the current branch name
93 # Usage example: git pull origin $(current_branch)
94 #
95 function current_branch() {
96 ref=$(git symbolic-ref HEAD 2> /dev/null) || \
97 ref=$(git rev-parse --short HEAD 2> /dev/null) || return
98 echo ${ref#refs/heads/}
99 }
100
101 function current_repository() {
102 ref=$(git symbolic-ref HEAD 2> /dev/null) || \
103 ref=$(git rev-parse --short HEAD 2> /dev/null) || return
104 echo $(git remote -v | cut -d':' -f 2)
105 }
106
107 # these aliases take advantage of the previous function
108 alias ggpull='git pull origin $(current_branch)'
109 compdef ggpull=git
110 alias ggpush='git push origin $(current_branch)'
111 compdef ggpush=git
112 alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
113 compdef ggpnp=git