Created
November 12, 2015 13:49
-
-
Save jovandeginste/983234ab83369481a971 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| : ${REMOTE:=origin} | |
| set -x | |
| git remote update $REMOTE --prune | |
| set +x | |
| TO_DELETE=$(diff <(git branch | cut -c 3-) <(git branch -r | cut -c 3- | grep $REMOTE | sed "s%^$REMOTE/%%") | grep '<' | awk '{print $2}') | |
| if [[ -z "$TO_DELETE" ]] | |
| then | |
| echo "No local branches to delete." | |
| exit | |
| fi | |
| echo "Deleting these (local) branches: $TO_DELETE" | |
| echo "Press enter to continue" | |
| read | |
| for B in $TO_DELETE | |
| do | |
| git branch -d $B | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment