Skip to content

Instantly share code, notes, and snippets.

@Sonictherocketman
Created October 10, 2017 22:50
Show Gist options
  • Save Sonictherocketman/d566dbc380804f9af4f6d08a89454e4c to your computer and use it in GitHub Desktop.
Save Sonictherocketman/d566dbc380804f9af4f6d08a89454e4c to your computer and use it in GitHub Desktop.
Interactively remove branches in a given git repository.
#! /bin/bash
# Interactively clean up branches in a given repository.
#
# author: Brian Schrader
# Usage: cd /path/to/repo && ./cleanup-git-branches
BRANCHES="$(git branch | sed 's/[ \*]//g')"
for BRANCH in $BRANCHES; do
CONFIRM_MSG=">>> Delete $BRANCH? [y/n, default: n]: "
read -en 1 -p "$CONFIRM_MSG";
if [[ "$REPLY" == "y" ]]; then
echo "Deleting $BRANCH"
git branch -D $BRANCH;
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment