Skip to content

Instantly share code, notes, and snippets.

@dchueri
Created January 2, 2023 01:30
Show Gist options
  • Save dchueri/211e228c8b53b6aaf18ebfec5fdf083d to your computer and use it in GitHub Desktop.
Save dchueri/211e228c8b53b6aaf18ebfec5fdf083d 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