Created
June 12, 2019 08:39
-
-
Save dannylagrouw/2cdaf21fd5bd94d7128e6cf33c41ba9b to your computer and use it in GitHub Desktop.
Lets user select a git branch to archive.
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 | |
echo "--------------------------------------------------------------------------------" | |
echo "Select a branch to archive" | |
echo "--------------------------------------------------------------------------------" | |
PS3="Branch no or 0 to quit> " | |
options=( $(git branch -l | grep --invert-match '*' | grep --invert-match 'master') ) | |
select opt in "${options[@]}"; do | |
if [[ $opt != '' ]]; then | |
echo "Archiving $opt ..." | |
git tag archive/$opt $opt | |
git branch -D $opt | |
echo "Done. To restore, type:" | |
echo "git checkout -b $opt archive/$opt" | |
fi | |
break | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment