Last active
June 22, 2020 17:57
-
-
Save jaredbeck/66f4e18d0d8834c508e35d6f77206be9 to your computer and use it in GitHub Desktop.
Loop over git branches, interactively inspecting/deleting them
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 bash | |
set -e | |
for BRANCH in $(git branch --format '%(refname:short)' | egrep -v '(master|dev)') | |
do | |
NEXT_BRANCH=false | |
until [ "$NEXT_BRANCH" = true ] | |
do | |
echo -e "\n$BRANCH" | |
git show "$BRANCH" | egrep '^Date:' | |
git diff --shortstat "$BRANCH" | |
echo "(d = delete, f = diff --stat, s = skip, q = quit)" | |
read CMD | |
case $CMD in | |
'd') | |
git branch -D "$BRANCH" | |
NEXT_BRANCH=true | |
;; | |
'f') | |
git diff --stat "$BRANCH" | |
;; | |
's') | |
echo 'Skipped' | |
NEXT_BRANCH=true | |
;; | |
'q') | |
exit 0 | |
;; | |
*) | |
esac | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment