Created
January 2, 2023 01:30
-
-
Save dchueri/211e228c8b53b6aaf18ebfec5fdf083d to your computer and use it in GitHub Desktop.
Clear Local Branches Script
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 "Starting..." | |
branch=$1 | |
delete() | |
{ | |
echo "Deleting branches..." | |
git branch --list | \ | |
egrep --invert-match "($branch|\*)" | \ | |
xargs git branch -D | |
echo "Done!" | |
} | |
if [ $# -lt 1 ] | |
then | |
echo "Error: You must provide your 'main' branch name (like 'main' or 'master')" | |
else | |
delete | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment