Skip to content

Git Aliases

The convention: lowercase for normal operations, uppercase for powerful or destructive ones.

AliasCommand
gagit add
gAgit add --all
gcgit commit
gCgit commit --amend
gcmgit commit -m
gCmgit commit --amend -m
AliasCommandNote
gpso [branch]git push originInteractive picker when no args
gPso [branch]git push --force originInteractive picker when no args
gplgit pull
gfgit fetch
AliasCommandNote
gbgit branchList
gsw [branch]git switchInteractive picker when no args
gswcgit switch -cCreate
grngit branch -mRename
AliasCommandNote
gmgit merge
gMgit merge --no-ffPreserve history
gmagit merge --abort
AliasCommandNote
gdgit diff
gDgit diff --cachedStaged changes
gdsgit diff --stat
AliasCommandNote
grgit rebase
gRgit rebase -iInteractive
grcgit rebase --continue
gragit rebase --abort
AliasCommand
grsgit reset
grs1git reset --hard HEAD~1
grs2git reset --hard HEAD~2
grs3git reset --hard HEAD~3
AliasCommandNote
grtgit restore
gRtgit restore --stagedUnstage
AliasCommand
gstgit stash
gStgit stash pop
gstagit stash apply
gstlgit stash list
gstdgit stash drop

These aliases switch between direct and interactive mode depending on whether you pass an argument.

AliasNo argsWith args
gswPick branch and switchSwitch to named branch
gpsoPick branch and pushPush named branch
gPsoPick branch and force pushForce push named branch

Interactive-only aliases:

AliasWhat it does
gbdPick a local branch to delete
gmePick a branch to merge with --no-ff --edit
gmesqPick a branch to squash merge
gprPick a base branch for PR creation
gloPick a branch and show log graph
gtrShow all branches as a log graph
AliasCommand
gsgit status -sb
gggit grep
gigit init
gclgit clone
CommandWhat it does
gifitPick 2 commits and view diff in difit
gdif [N]View diff for last N commits (default: 1)
Terminal window
# Interactive commit range selection
gifit
# Review the last commit
gdif
# Review the last 3 commits
gdif 3