Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shospodarets/2f541c6687f319f41763ac7c7db70c12 to your computer and use it in GitHub Desktop.
Save shospodarets/2f541c6687f319f41763ac7c7db70c12 to your computer and use it in GitHub Desktop.
Remove Git branches, which are merged to the current one (+ ability to exclude some of them)
#!/usr/bin/env bash
# based on https://gist.github.com/schacon/942899
# list
git branch -r --merged | grep origin | grep -v '>' | grep -v master\* | grep -v release-\* | xargs -L1
# delete
git branch -r --merged | grep origin | grep -v '>' | grep -v master\* | grep -v release-\* | xargs -L1 | awk '{sub(/origin\//,"");print}' | xargs git push origin --delete
@shospodarets
Copy link
Author

alt

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