Skip to content

Instantly share code, notes, and snippets.

@filipelinhares
Last active June 23, 2017 22:44
Show Gist options
  • Save filipelinhares/0dc41ace55a0589e9b66922ba5041274 to your computer and use it in GitHub Desktop.
Save filipelinhares/0dc41ace55a0589e9b66922ba5041274 to your computer and use it in GitHub Desktop.
git delete-squashed-branches
# Put in your ~/.somethingrc file
# source: https://github.com/not-an-aardvark/git-delete-squashed
git-delete-squashed-branches () {
git checkout -q master && git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do mergeBase=$(git merge-base master $branch) && [[ $(git cherry master $(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