Skip to content

Instantly share code, notes, and snippets.

@puranjayjain
Created May 27, 2020 06:20
Show Gist options
  • Save puranjayjain/01b3c5082eb9fd0bc545ce185cec7450 to your computer and use it in GitHub Desktop.
Save puranjayjain/01b3c5082eb9fd0bc545ce185cec7450 to your computer and use it in GitHub Desktop.
Delete all git branches on remote except the ones mentioned to ignore

About

This unsafe and destructive command deletes all the prigin branches except the ones mentioned as grep -v 'uat'

List command

git branch --remote | grep -v 'dev' | grep -v 'qa' | grep -v 'uat' | grep -v 'master' | cut -b 10- | xargs

Deletion command

git branch --remote | grep -v 'dev' | grep -v 'qa' | grep -v 'uat' | grep -v 'master' | cut -b 10- | xargs git push --delete origin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment