Skip to content

Instantly share code, notes, and snippets.

@chrisjrn
Created July 28, 2021 18:08
Show Gist options
  • Select an option

  • Save chrisjrn/b03e45c206beb015d392a0e20454bbc7 to your computer and use it in GitHub Desktop.

Select an option

Save chrisjrn/b03e45c206beb015d392a0e20454bbc7 to your computer and use it in GitHub Desktop.
alias git-delete-squashed='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'
@chrisjrn
Copy link
Author

If you want to test, you can replace the final git branch -D with a simple echo

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