Skip to content

Instantly share code, notes, and snippets.

@alloy-d
Created August 19, 2013 18:23
Show Gist options
  • Save alloy-d/6272371 to your computer and use it in GitHub Desktop.
Save alloy-d/6272371 to your computer and use it in GitHub Desktop.
# It is acknowledged that all perl one-liners here are both inelegant
# and probably great targets for replacement with sed.
# Get a list of fully merged branches:
git branch --merged | perl -pe '$_ =~ s/..//' > branches
# edit branches to exclude branches that shouldn't be deleted (example: master)
# Delete branches locally:
xargs git branch -d < branches
# Delete remote branches:
perl -pe '$_ =~ s/^/:/' < branches | xargs git push origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment