Skip to content

Instantly share code, notes, and snippets.

@funkyfisch
Created April 19, 2020 22:01
Show Gist options
  • Save funkyfisch/99caa412e7d8d62661655e0136255a78 to your computer and use it in GitHub Desktop.
Save funkyfisch/99caa412e7d8d62661655e0136255a78 to your computer and use it in GitHub Desktop.
How to delete all local git branches apart from master
#!/bin/bash
git checkout master \
&& git for-each-ref --format='%(refname:short)' refs/heads/ \
| grep -v "^master$" \
| xargs git branch -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment