Skip to content

Instantly share code, notes, and snippets.

@lloiacono
Last active August 16, 2018 16:09
Show Gist options
  • Save lloiacono/fa6aff2251f4900b52e82cc6b833db2c to your computer and use it in GitHub Desktop.
Save lloiacono/fa6aff2251f4900b52e82cc6b833db2c to your computer and use it in GitHub Desktop.
Delete local branches
#!/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