Created
February 12, 2020 13:08
-
-
Save motia/02dd8a1a6012d21e5b7aec9d3d5b496b to your computer and use it in GitHub Desktop.
Remove branches merged into the current 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
function remove-merged-branches () { | |
currentBranch=$(git rev-parse --abbrev-ref HEAD) | |
read -p "Delete branches merges into $currentBranch y/N? " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
git branch --merged | grep -v $currentBranch | while read i; do git branch -d $i; done; | |
echo "Branches removed successfully" | |
else | |
echo "Operation canceled" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment