Skip to content

Instantly share code, notes, and snippets.

@wayne-weibel
Last active September 12, 2018 20:58
Show Gist options
  • Save wayne-weibel/c8f246249c79dc4896ef5749327ec8b8 to your computer and use it in GitHub Desktop.
Save wayne-weibel/c8f246249c79dc4896ef5749327ec8b8 to your computer and use it in GitHub Desktop.
single line bash command to delete remote repos. replace grep regex as necessary (but i would leave 'master' included lol)
for branch in `git branch -a | awk -F"/" '{ print $3 }' | grep -Pv '^(master|develop)' | grep -P '^\d'`; do echo $branch; git push origin --delete $branch; done
@wayne-weibel
Copy link
Author

the second grep is to eliminate 'HEAD', '->', and 'origin' from the list being processed. the branches i am dealing with all begin with a ticket number

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