Skip to content

Instantly share code, notes, and snippets.

@klondikemarlen
Created February 27, 2026 16:23
Show Gist options
  • Select an option

  • Save klondikemarlen/ea6283fe03c9774fd5c54b18d483f518 to your computer and use it in GitHub Desktop.

Select an option

Save klondikemarlen/ea6283fe03c9774fd5c54b18d483f518 to your computer and use it in GitHub Desktop.
Git aliases for streamlined workflow including branch management, rebasing, and orphan branch cleanup
[alias]
co = checkout
chp = cherry-pick
r = rebase
rom = rebase origin/main
rot = rebase origin/test
blg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
br = branch
ci = commit
st = status
ss = stash --staged
alias = config --get-regexp alias
fetch-and-prune-all = !git fetch --prune --all && git pull
fpa = fetch-and-prune-all
ls-orphans = !git for-each-ref --format '%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(end)' refs/heads | awk 'length($1) > 0'
lso = ls-orphans
purge-orphans = !"for branch in $(git ls-orphans); do git branch -d $branch; done"
purge-orphans-force = !"for branch in $(git ls-orphans); do git branch -d $branch; done"
po = purge-orphans
pof = purge-orphans-force
sync-branches = !git fetch-and-prune-all && git purge-orphans
sb = sync-branches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment