ZSH Git plugin

The git plugin provides many aliases and a few useful functions.

To use it, add git to the plugins array in your zshrc file:

1
plugins=(... git)

Aliases

AliasCommand
ggit
gagit add
gaagit add –all
gapagit add –patch
gaugit add –update
gavgit add –verbose
gapgit apply
gbgit branch
gbagit branch -a
gbdgit branch -d
gbdagit branch –no-color –merged | command grep -vE “^(+|*|\s*(master|develop|dev)\s*$)” | command xargs -n 1 git branch -d
gbDgit branch -D
gblgit blame -b -w
gbnmgit branch –no-merged
gbrgit branch –remote
gbsgit bisect
gbsbgit bisect bad
gbsggit bisect good
gbsrgit bisect reset
gbssgit bisect start
gcgit commit -v
gc!git commit -v –amend
gcn!git commit -v –no-edit –amend
gcagit commit -v -a
gca!git commit -v -a –amend
gcan!git commit -v -a –no-edit –amend
gcans!git commit -v -a -s –no-edit –amend
gcamgit commit -a -m
gcsmgit commit -s -m
gcbgit checkout -b
gcfgit config –list
gclgit clone –recurse-submodules
gcleangit clean -id
gpristinegit reset –hard && git clean -dffx
gcmgit checkout master
gcdgit checkout develop
gcmsggit commit -m
gcogit checkout
gcountgit shortlog -sn
gcpgit cherry-pick
gcpagit cherry-pick –abort
gcpcgit cherry-pick –continue
gcsgit commit -S
gdgit diff
gdcagit diff –cached
gdcwgit diff –cached –word-diff
gdctgit describe –tags $(git rev-list –tags –max-count=1)
gdsgit diff –staged
gdtgit diff-tree –no-commit-id –name-only -r
gdvgit diff -w $@ | view -
gdwgit diff –word-diff
gfgit fetch
gfagit fetch –all –prune
gfggit ls-files | grep
gfogit fetch origin
gggit gui citool
ggagit gui citool –amend
ggfgit push –force origin $(current_branch)
ggflgit push –force-with-lease origin $(current_branch)
gglgit pull origin $(current_branch)
ggpgit push origin $(current_branch)
ggpnpggl && ggp
ggpullgit pull origin “$(git_current_branch)”
ggpurggu
ggpushgit push origin “$(git_current_branch)”
ggsupgit branch –set-upstream-to=origin/$(git_current_branch)
ggugit pull –rebase origin $(current_branch)
gpsupgit push –set-upstream origin $(git_current_branch)
ghhgit help
gignoregit update-index –assume-unchanged
gignoredgit ls-files -v | grep “^[[:lower:]]”
git-svn-dcommit-pushgit svn dcommit && git push github master:svntrunk
gkgitk –all –branches
gkegitk –all $(git log -g –pretty=%h)
glgit pull
glggit log –stat
glgpgit log –stat -p
glgggit log –graph
glggagit log –graph –decorate –all
glgmgit log –graph –max-count=10
glogit log –oneline –decorate
glolgit log –graph –pretty=’%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
glolsgit log –graph –pretty=’%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset’ –stat
glodgit log –graph –pretty=’%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'
glodsgit log –graph –pretty=’%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset’ –date=short
glolagit log –graph –pretty=’%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset’ –all
gloggit log –oneline –decorate –graph
glogagit log –oneline –decorate –graph –all
glp_git_log_prettily
gmgit merge
gmomgit merge origin/master
gmtgit mergetool –no-prompt
gmtvimgit mergetool –no-prompt –tool=vimdiff
gmumgit merge upstream/master
gmagit merge –abort
gpgit push
gpdgit push –dry-run
gpfgit push –force-with-lease
gpf!git push –force
gpoatgit push origin –all && git push origin –tags
gpugit push upstream
gpvgit push -v
grgit remote
gragit remote add
grbgit rebase
grbagit rebase –abort
grbcgit rebase –continue
grbdgit rebase develop
grbigit rebase -i
grbmgit rebase master
grbsgit rebase –skip
grevgit revert
grhgit reset
grhhgit reset –hard
grohgit reset origin/$(git_current_branch) –hard
grmgit rm
grmcgit rm –cached
grmvgit remote rename
grrmgit remote remove
grsgit restore
grsetgit remote set-url
grssgit restore –source
grtcd “$(git rev-parse –show-toplevel || echo .)”
grugit reset –
grupgit remote update
grvgit remote -v
gsbgit status -sb
gsdgit svn dcommit
gshgit show
gsigit submodule init
gspsgit show –pretty=short –show-signature
gsrgit svn rebase
gssgit status -s
gstgit status
gstagit stash push
gstagit stash save
gstaagit stash apply
gstcgit stash clear
gstdgit stash drop
gstlgit stash list
gstpgit stash pop
gstsgit stash show –text
gstugit stash –include-untracked
gstallgit stash –all
gsugit submodule update
gswgit switch
gswcgit switch -c
gtsgit tag -s
gtvgit tag | sort -V
gtlgtl(){ git tag –sort=-v:refname -n -l ${1}* }; noglob gtl
gunignoregit update-index –no-assume-unchanged
gunwipgit log -n 1 | grep -q -c “--wip--” && git reset HEAD~1
gupgit pull –rebase
gupvgit pull –rebase -v
gupagit pull –rebase –autostash
gupavgit pull –rebase –autostash -v
glumgit pull upstream master
gwchgit whatchanged -p –abbrev-commit –pretty=medium
gwipgit add -A; git rm $(git ls-files –deleted) 2> /dev/null; git commit –no-verify –no-gpg-sign -m “–wip– [skip ci]”

Deprecated aliases

These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.

AliasCommandModification
gapgit add --patchnew alias gapa
gclgit config --listnew alias gcf
gdcgit diff --cachednew alias gdca
gdtgit difftoolno replacement
ggpullgit pull origin $(current_branch)new alias ggl (ggpull still exists for now though)
ggpurgit pull --rebase origin $(current_branch)new alias ggu (ggpur still exists for now though)
ggpushgit push origin $(current_branch)new alias ggp (ggpush still exists for now though)
gkgitk --all --branchesnow aliased to gitk --all --branches
glggit log --stat --max-count = 10now aliased to git log --stat --color
glgggit log --graph --max-count = 10now aliased to git log --graph --color
gwcgit whatchanged -p --abbrev-commit --pretty = mediumnew alias gwch

Functions

Current

CommandDescription
grename <old> <new>Rename old branch to new, including in origin remote
current_branchReturn the name of the current branch
git_current_user_nameReturns the user.name config value
git_current_user_emailReturns the user.email config value

Work in Progress (WIP)

These features allow to pause a branch development and switch to another one (“Work in Progress”, or wip). When you want to go back to work, just unwip it.

CommandDescription
work_in_progressEchoes a warning if the current branch is a wip
gwipCommit wip branch
gunwipUncommit wip branch

Deprecated functions

CommandDescriptionReason
current_repositoryReturn the names of the current remotesDidn’t work properly. Use git remote -v instead (grv alias)