Created
June 24, 2014 19:47
-
-
Save robhurring/acf1a4491d771838027e to your computer and use it in GitHub Desktop.
Cleans up branches merged into "dev" from your local repo (except current branch, dev, and master)
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
#!/usr/bin/env sh | |
# IMPORTANT: exclude the current branch (*), master and dev branch. Add any other patterns here | |
# and do a --dry-run if you're unsure | |
to_prune=$(git branch --merged dev | grep -v '\*\|master\|dev') | |
function show_help { | |
echo Usage: $(basename $0) | |
echo " -n [--dry-run] Print branches that would be removed" | |
} | |
case "$1" in | |
-n|--dry-run) | |
echo "\033[1;37mBranches that would be deleted (locally):\033[0m" | |
for branch in $to_prune; do | |
echo " \033[31m$branch\033[0m" | |
done | |
;; | |
-h) | |
show_help | |
;; | |
*) | |
for branch in $to_prune; do | |
echo "\033[31m$IBAD $(git branch -d $branch)\033[0m" | |
done | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment