Created
August 10, 2019 01:07
-
-
Save paulscott/663acf68433fef75c436f29ed06b17da to your computer and use it in GitHub Desktop.
Utility to show squash-merged branches that should be pruned
This file contains hidden or 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/bash | |
git for-each-ref refs/heads/ "--format=%(refname:short)" | | |
while read branch; do | |
mergeBase=$(git merge-base HEAD "${branch}" ) | |
tree=$(git rev-parse "${branch}^{tree}") | |
tempCommit=$(git commit-tree "${tree}" -p "${mergeBase}" -m "_" ) | |
if [[ $(git cherry HEAD "${tempCommit}") == "-"* ]]; then | |
echo "git branch -D ${branch}" | |
fi | |
done | |
git prune |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment