Skip to content

Instantly share code, notes, and snippets.

@cristianossd
Created May 15, 2023 13:44
Show Gist options
  • Save cristianossd/a46d1f315b165a347e1d9000ea565eb3 to your computer and use it in GitHub Desktop.
Save cristianossd/a46d1f315b165a347e1d9000ea565eb3 to your computer and use it in GitHub Desktop.
Delete git repository branches locally in a single command (bash, zsh)
# delete branches locally except main
alias git-delete-branches='git branch | egrep -v "(^\*|main)" | xargs git branch -D'
# just run git-delete-branches whenever you want
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment