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