Created
October 10, 2017 22:50
-
-
Save Sonictherocketman/d566dbc380804f9af4f6d08a89454e4c to your computer and use it in GitHub Desktop.
Interactively remove branches in a given git repository.
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
#! /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