Created
April 29, 2019 23:45
-
-
Save colbyfayock/20982cd88760c2abc3e6c7bdc3a85dda to your computer and use it in GitHub Desktop.
Remove local branches that merged into the specified branch
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
# Example Usage: gpb develop | |
# Removes any branches that were already merged into develop | |
gpb() { | |
BRANCH=$1 | |
BRANCHES_TO_CLEAN=$(git branch --merged=$BRANCH | grep -v $BRANCH) | |
echo "Branches that have been merged to develop:" | |
echo $BRANCHES_TO_CLEAN | |
read -q "REPLY?Remove branches? (y/n)" | |
echo "" | |
if [ "$REPLY" != "y" ]; then | |
echo "Response was not \"y\", aborting..." | |
return | |
fi | |
echo "Removing branches from local" | |
for i in `echo $BRANCHES_TO_CLEAN`; do | |
git branch -D $i | |
done | |
echo "Done." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment