Skip to content

Instantly share code, notes, and snippets.

@Masynchin
Created June 12, 2022 23:37
Show Gist options
  • Save Masynchin/e86cc524c16a7063f3f98c45d0987b73 to your computer and use it in GitHub Desktop.
Save Masynchin/e86cc524c16a7063f3f98c45d0987b73 to your computer and use it in GitHub Desktop.
Delete all git branches except main
# Shamelessly stolen from https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/delete-all-branches-except-master-main-local-remote
# using ripgrep instead of grep, so it is two symbols shorter :)
git branch | rg -v 'main' | xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment