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