Created
March 11, 2020 16:20
-
-
Save jjgonecrypto/a05d1091b0f73f5d25b05dbefa6898e5 to your computer and use it in GitHub Desktop.
git-delete-squashed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# adapted from https://github.com/not-an-aardvark/git-delete-squashed | |
function git-delete-squashed() { | |
BASE_BRANCH=${1:-master} | |
git checkout -q $BASE_BRANCH && | |
git for-each-ref refs/heads/ "--format=%(refname:short)" | | |
while read branch; | |
do mergeBase=$(git merge-base $BASE_BRANCH $branch) && [[ $(git cherry $BASE_BRANCH $(git commit-tree $(git rev-parse $branch\^{tree}) -p $mergeBase -m _)) == "-"* ]] && | |
git branch -D $branch; | |
done | |
} | |
# e.g. usage with a named branch: | |
# git-delete-squashed develop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment