Skip to content

Instantly share code, notes, and snippets.

@thecodejunkie
Created November 7, 2015 11:05
Show Gist options
  • Save thecodejunkie/f1c5fdd30c97d8e0d766 to your computer and use it in GitHub Desktop.
Save thecodejunkie/f1c5fdd30c97d8e0d766 to your computer and use it in GitHub Desktop.
Delete merged branches, both in origin and locally
1. Delete the branches in my remote `origin`
git branch -r --merged | grep "\origin" | grep -v "\master" | cut -d"/" -f 2 | xargs -n 1 git push origin --delete
2. Delete the branches locally
git branch --merged master | grep -v "\master" | xargs -n 1 git branch -D
@andreasohlund
Copy link

Would -d for the local delete be safer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment