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