Created
August 6, 2020 11:35
-
-
Save makotoshimazu/12f55e6d1580a9f21d0ccfad8a1d4610 to your computer and use it in GitHub Desktop.
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
#!/bin/zsh | |
autoload -Uz colors | |
colors | |
echo " hash | branch" | |
echo "--------+----------------------" | |
git branch -vv | grep gone | sed -E 's/ +/ /g' | cut -d ' ' -f 2,3 | | |
while read branch_name rev | |
do | |
#echo "branch: ${fg[green]}${branch_name}${reset_color} revision: ${fg[green]}${rev}${reset_color}" | |
printf "${fg[green]}%-8s${reset_color}| %s\n" "${rev}" "${branch_name}" | |
done | |
echo "" | |
echo -n "Are you okay to remove these branches? [y/N]: " | |
read RESULT | |
case $RESULT in | |
[Yy]) | |
;; | |
*) | |
exit 1 | |
;; | |
esac | |
git branch -vv | grep gone | sed -E 's/ +/ /g' | cut -d ' ' -f 2,3 | | |
while read branch_name rev | |
do | |
tag_name="archived__${branch_name}" | |
git tag ${tag_name} ${rev} | |
git branch -D ${branch_name} | |
echo "Created a tag: ${tag_name} (${rev})" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment