Skip to content

Instantly share code, notes, and snippets.

@alecbz
Created May 23, 2019 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alecbz/8eb61026a2c93818802b20c1f2b5b0a7 to your computer and use it in GitHub Desktop.
Save alecbz/8eb61026a2c93818802b20c1f2b5b0a7 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -u
git fetch --all --quiet
for b in $(git for-each-ref refs/heads --format="%(refname:short)"); do
if [[ ! $(git cherry -v origin/master $b | grep "^+") ]]; then
git branch -D $b
elif git diff --exit-code --quiet "origin/master...${b}"; then
git branch -D $b
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment