Skip to content

Instantly share code, notes, and snippets.

@talentedmrjones
Last active January 17, 2025 16:50
Show Gist options
  • Save talentedmrjones/796c42749d8059a49413644c19f3fd25 to your computer and use it in GitHub Desktop.
Save talentedmrjones/796c42749d8059a49413644c19f3fd25 to your computer and use it in GitHub Desktop.
Easily keep your git repo clean by automating pruning and deleting stale branches. Simply add this line to .zshrc (or other shell config)
# checkout main
# pull origin
# prune origin
# delete local branches that were pruned from origin
alias gpmp="git checkout main && git pull && git remote prune origin | grep \"\[pruned\]\" | xargs -I % echo % | sed -e 's/\* \[pruned\] origin\///g' | xargs -I % git branch -D %"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment