Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash -e
- REMOTE="$1"
- BRANCH="$2"
- if [ !$REMOTE ]; then
- REMOTE="origin"
- fi
- if [ !$BRANCH ]; then
- BRANCH="master"
- fi
- git fetch $REMOTE
- MERGEDBRANCHES=(`git log $REMOTE/$BRANCH --merges | ack --match "Merge pull request" | ack -o --match "[A-z0-9\-_\/]+$" | sed -E 's_^[A-z0-9\-_]+/__'`)
- LOCALBRANCHES=(`git branch | ack -o --match "[A-z0-9-_\/]+$"`)
- TOREMOVE=()
- SEARCH=" ${MERGEDBRANCHES[*]} "
- for BRANCH in "${LOCALBRANCHES[@]}"; do
- if [[ $SEARCH =~ " $BRANCH " ]]; then
- TOREMOVE+=($BRANCH)
- fi
- done
- for RMBRANCH in "${TOREMOVE[@]}"; do
- git branch -D $RMBRANCH
- done
- git remote prune $REMOTE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement