Skip to content

Instantly share code, notes, and snippets.

@nocash
Last active March 24, 2016 18:24
Show Gist options
  • Save nocash/3352c2c5001b68c98b1c to your computer and use it in GitHub Desktop.
Save nocash/3352c2c5001b68c98b1c to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
current=`git symbolic-ref --quiet --short HEAD`
exclude="^(master|develop)"
git fetch origin
git checkout master
git reset --hard origin/master
git branch --merged origin/master \
| cut -c3- \
| grep -v "$exclude" \
| xargs git branch --delete
git checkout "$current"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment