Skip to content

Instantly share code, notes, and snippets.

@mladenoff
Last active October 16, 2024 21:15
Show Gist options
  • Save mladenoff/5f47a8063585cc7602e4ded43a0b5cea to your computer and use it in GitHub Desktop.
Save mladenoff/5f47a8063585cc7602e4ded43a0b5cea to your computer and use it in GitHub Desktop.
Zsh Git Commands

Zsh Git Commands

These are sorted alpha by command, rather than by alias, which is truly useless.

Command Alias
cd "$(git rev-parse --show-toplevel || echo .)" grt
git add ga
git add --all gaa
git add --patch gapa
git add --update gau
git add --verbose gav
git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" gwip
git am gam
git am --abort gama
git am --continue gamc
git am --show-current-patch gamscp
git am --skip gams
git apply gap
git apply --3way gapt
git bisect gbs
git bisect bad gbsb
git bisect good gbsg
git bisect reset gbsr
git bisect start gbss
git blame -b -w gbl
git branch gb
git branch -a gba
git branch -d gbd
git branch -D gbD
git branch --no-color --merged | grep -vE "^([+]|\s($(git_main_branch)|$(git_develop_branch))\s*$)" | xargs git branch -d 2>/dev/null gbda
git branch --no-merged gbnm
git branch --remote gbr
git branch --set-upstream-to=origin/$(git_current_branch) ggsup
git checkout gco
git checkout $(git_develop_branch) gcd
git checkout $(git_main_branch) gcm
git checkout -b gcb
git checkout --recurse-submodules gcor
git cherry-pick gcp
git cherry-pick --abort gcpa
git cherry-pick --continue gcpc
git clean -id gclean
git clone --recurse-submodules gcl
git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" gccd
git commit -a -m gcam
git commit -a -s gcas
git commit -a -s -m gcasm
git commit -S gcs
git commit -s -m gcsm
git commit -v gc
git commit -v -a gca
git commit -v -a --amend gca!
git commit -v -a --no-edit --amend gcan!
git commit -v -a -s --no-edit --amend gcans!
git commit -v --amend gc!
git commit -v --no-edit --amend gcn!
git config --list gcf
git describe --tags $(git rev-list --tags --max-count=1) gdct
git diff gd
git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" gdnolock
git diff --cached gdca
git diff --cached --word-diff gdcw
git diff --staged gds
git diff --word-diff gdw
git diff -w $@ | view - gdv
git diff @{upstream} gdup
git diff-tree --no-commit-id --name-only -r gdt
git fetch gf
git fetch --all --prune gfa
git fetch origin gfo
git gui citool gg
git gui citool --amend gga
git help ghh
git log --graph glgg
git log --graph --decorate --all glgga
git log --graph --max-count=10 glgm
git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' glod
git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short glods
git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' glol
git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all glola
git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat glols
git log --oneline --decorate glo
git log --oneline --decorate --graph glog
git log --oneline --decorate --graph --all gloga
git log --pretty=<format> glp
git log --stat glg
git log --stat -p glgp
git log -n 1 | grep -q -c "--wip--" && git reset HEAD~1 gunwip
git ls-files | grep gfg
git ls-files -v | grep "^[[:lower:]]" gignored
git merge gm
git merge --abort gma
git merge origin/$(git_main_branch) gmom
git merge upstream/$(git_main_branch) gmum
git mergetool --no-prompt gmtl
git mergetool --no-prompt --tool=vimdiff gmtlvim
git pull gl
git pull --rebase gup
git pull --rebase --autostash gupa
git pull --rebase --autostash -v gupav
git pull --rebase -v gupv
git pull --rebase origin $(current_branch) ggu
git pull --rebase origin $(git_main_branch) gupom
git pull --rebase=interactive origin $(git_main_branch) gupomi
git pull origin "$(git_current_branch)" ggpull
git pull origin $(current_branch) ggl
git pull upstream $(git_current_branch) gluc
git pull upstream $(git_main_branch) glum
git push gp
git push --dry-run gpd
git push --force origin $(current_branch) ggf
git push --force-with-lease gpf
git push --force-with-lease origin $(current_branch) ggfl
git push --force gpf!
git push --set-upstream origin $(git_current_branch) gpsup
git push -v gpv
git push origin "$(git_current_branch)" ggpush
git push origin $(current_branch) ggp
git push origin --all && git push origin --tags gpoat
git push upstream gpu
git rebase grb
git rebase --abort grba
git rebase --continue grbc
git rebase --onto grbo
git rebase --skip grbs
git rebase $(git_develop_branch) grbd
git rebase $(git_main_branch) grbm
git rebase -i grbi
git rebase origin/$(git_main_branch) grbom
git remote gr
git remote add gra
git remote rename grmv
git remote remove grrm
git remote set-url grset
git remote update grup
git remote -v grv
git reset grh
git reset -- gru
git reset --hard grhh
git reset --hard && git clean -dffx gpristine
git reset origin/$(git_current_branch) --hard groh
git restore grs
git restore --source grss
git restore --staged grst
git revert grev
git rm grm
git rm --cached grmc
git shortlog -sn gcount
git show gsh
git show --pretty=short --show-signature gsps
git stash apply gstaa
git stash clear gstc
git stash drop gstd
git stash list gstl
git stash pop gstp
git stash push gsta
git stash save gsta
git stash show --text gsts
git stash --all gstall
git stash --include-untracked gstu
git status gst
git status -s gss
git status -sb gsb
git submodule init gsi
git submodule update gsu
git svn dcommit gsd
git svn dcommit && git push github $(git_main_branch):svntrunk git-svn-dcommit-push
git svn rebase gsr
git switch gsw
git switch $(git_develop_branch) gswd
git switch $(git_main_branch) gswm
git switch -c gswc
git tag -s gts
git tag | sort -V gtv
git update-index --assume-unchanged gignore
git update-index --no-assume-unchanged gunignore
git whatchanged -p --abbrev-commit --pretty=medium gwch
git g
gitk --all $(git log -g --pretty=%h) &! gke
gitk --all --branches &! gk
ggl && ggp ggpnp
gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl gtl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment