Home

Awesome

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:

plugins=(... git)

Aliases

AliasCommand
ggit
gagit add
gaagit add --all
gapagit add --patch
gaugit add --update
gavgit add --verbose
gapgit apply
gaptgit apply --3way
gbgit branch
gbagit branch -a
gbdgit branch -d
gbdagit branch --no-color --merged | command grep -vE "^(+|*|\s*($(git_main_branch)|development|develop|devel|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
gcasgit commit -a -s
gcasmgit commit -a -s -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 $(git_main_branch)
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
gdnolockgit diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock"
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 $(git_main_branch):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
glpgit log --pretty=<format>
gmgit merge
gmomgit merge origin/$(git_main_branch)
gmtgit mergetool --no-prompt
gmtvimgit mergetool --no-prompt --tool=vimdiff
gmumgit merge upstream/$(git_main_branch)
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 $(git_main_branch)
grbogit rebase --onto
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
grstgit restore --staged
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 $(git_main_branch)
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]"
gamgit am
gamcgit am --continue
gamsgit am --skip
gamagit am --abort
gamscpgit am --show-current-patch

Main branch preference

Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using a branch name other than master. In this case, we favor the shorter, neutral and descriptive term main. This means that any aliases and functions that previously used master, will use main if that branch exists. We do this via the function git_main_branch.

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
git_main_branchReturns the name of the main branch: main if it exists, master otherwise

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)