Last active
September 9, 2022 13:59
-
-
Save Ghostbird/f6db35c06973040d6ded585be2d3970f to your computer and use it in GitHub Desktop.
Script to delete merged branches
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/bash | |
branches=$(git branch --merged | grep -Ev "^\*|develop|master|main") | |
if [ "$branches" ] | |
then | |
git branch -d $branches | |
else | |
echo "Nothing to delete" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save it in your PATH and you can call it as:
git branch-delete-merged
. It should automatically work with git completion if you have it set up.