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