Skip to content

Instantly share code, notes, and snippets.

@GerardoHP
Created November 7, 2021 16:48
Show Gist options
  • Save GerardoHP/dc5d2814fca1dd71eee2639ebe7ab09f to your computer and use it in GitHub Desktop.
Save GerardoHP/dc5d2814fca1dd71eee2639ebe7ab09f to your computer and use it in GitHub Desktop.
SH to delete all of the branches excluding some
cd /c/Users/ghern/source/repos/bn3/bn3-backend-${1}
current_branch=$(git branch --show-current)
branches_to_delete=$(git branch -l | grep -v "dev" | grep -v "release/1.0.0" | grep -v $current_branch)
for branch in $branches_to_delete; do
git branch -D ${branch}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment