Last active
August 16, 2018 16:09
-
-
Save lloiacono/fa6aff2251f4900b52e82cc6b833db2c to your computer and use it in GitHub Desktop.
Delete local 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 | |
| # Script to loop through local branches and delete them based on user input | |
| for branch in `git branch | grep -v HEAD | grep -v master | grep -v \* | sort`; | |
| do | |
| read -p "Would you like to delete the branch $branch? [Y/n] " -n 1 -r | |
| echo | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| git branch -D $branch | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment