Skip to content

Instantly share code, notes, and snippets.

@matthew-healy
Created January 9, 2020 19:31
Show Gist options
  • Save matthew-healy/d4d4f2097f913c6ace82ac5c54374d32 to your computer and use it in GitHub Desktop.
Save matthew-healy/d4d4f2097f913c6ace82ac5c54374d32 to your computer and use it in GitHub Desktop.
How do I delete all local branches except master and the one I'm currently on?
#!/usr/bin/env bash
current_branch_name=`git rev-parse --abbrev-ref HEAD`
git branch \
| grep -v master \
| grep -v $current_branch_name \
| xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment