Last active
December 20, 2024 13:19
-
-
Save fmartins-andre/086d16f0747bc95a17c31d1a27cbf622 to your computer and use it in GitHub Desktop.
Remove local branches that were merged
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 | |
echo 'Removing origins...' | |
git remote prune origin | |
BRANCHES=`git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}'` | |
if [[ `echo -e "$BRANCHES" | wc -w` -gt 0 ]]; then | |
echo 'Removing branches:' | |
echo $BRANCHES | |
echo $BRANCHES | xargs git branch -D | |
else | |
echo 'No branches to delete' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment