Last active
September 1, 2023 15:11
-
-
Save donmccurdy/67004e5fcf520cf94f934c9459a04e2c to your computer and use it in GitHub Desktop.
Clean up old Git branches.
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 | |
echo "Cleaning up git branches..." | |
git branch --format="%(refname:short)" | grep -v -E "master|dev" | while read branchname; do | |
read -n 1 -p $'\nDelete branch '"$branchname"$'? (Yn)\n' yn </dev/tty | |
case ${yn:0:1} in | |
y|Y ) | |
git branch -D $branchname | |
;; | |
* ) | |
echo "Skipping" | |
;; | |
esac | |
done | |
echo "...done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment