Skip to content

Instantly share code, notes, and snippets.

@israelss
Forked from dchueri/clear-branches.sh
Created July 10, 2023 21:38
Show Gist options
  • Save israelss/a26f4d6b3e104cc3ffc64f29967119fd to your computer and use it in GitHub Desktop.
Save israelss/a26f4d6b3e104cc3ffc64f29967119fd to your computer and use it in GitHub Desktop.
Clear Local Branches Script
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