Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iPublicis/e38b951076eb57dd694ff3ea3698f2e0 to your computer and use it in GitHub Desktop.
Save iPublicis/e38b951076eb57dd694ff3ea3698f2e0 to your computer and use it in GitHub Desktop.
Delete feature branch with prefix locally then remove all remote feature branches
# Stole from:
# http://stackoverflow.com/questions/32122784/alias-script-to-delete-all-local-and-remote-git-branches-with-a-specific-prefix
git branch -D $(printf "%s\n" $(git branch) | grep 'feature/')
# Or this will work too to remove all remote branches:
# https://coderwall.com/p/eis0ba/remove-a-thousand-stale-remote-branches-on-git
git branch -r | awk -F/ '/\/feature/{print $2}' | xargs -I {} git push origin :{}
# Prune all origin branches
git remote prune origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment