Created
October 25, 2016 08:06
-
-
Save phraemer/4cb3f83e008a0cd722086a670e26bc2f to your computer and use it in GitHub Desktop.
Script deletes any merged remote branches after confirmation
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 | |
branchesToDelete=`git branch --merged | egrep -v "(^\*|master)"` | |
echo "The following branches will be deleted..." | |
echo ${branchesToDelete} | |
read -p "Are you sure? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
# do dangerous stuff | |
echo ${branchesToDelete} | xargs git branch -d | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment