Skip to content

Instantly share code, notes, and snippets.

@dsturley
Created June 28, 2017 23:37
Show Gist options
  • Save dsturley/958a40be5db270dbf84b5957efcab6fd to your computer and use it in GitHub Desktop.
Save dsturley/958a40be5db270dbf84b5957efcab6fd to your computer and use it in GitHub Desktop.
remove branches that were squashed and merged into develop
#!/bin/bash
git checkout -q develop && git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do mergeBase=$(git merge-base develop $branch) && [[ $(git cherry develop $(git commit-tree $(git rev-parse $branch^{tree}) -p $mergeBase -m _)) == "-"* ]] && git branch -D $branch; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment