Last active
August 29, 2015 14:22
-
-
Save nolandc/f070fe8eef1911e56a8d to your computer and use it in GitHub Desktop.
Interactive Git Branch Deletion
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
| echo "Git Branch Deleletion (Interactive)" | |
| # Grep out the current branch and branches too important to delete | |
| list=$(git branch --list | grep -v \* | grep -v develop | grep -v master) | |
| if [[ $list == '' ]]; then | |
| echo "There are no branches to delete." | |
| exit 0 | |
| fi | |
| while read -r line; do | |
| printf "Delete the branch '$line' ? [y/N]:" | |
| read toDelete </dev/tty | |
| if [[ $toDelete == 'y' ]]; then | |
| git branch -D $line | |
| else | |
| echo "Not deleting $line" | |
| fi | |
| echo | |
| done <<< "$list" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment