Skip to content

Instantly share code, notes, and snippets.

@kirbysayshi
Last active March 18, 2020 20:12
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 kirbysayshi/4b4576d23b271d93e71c33544acb5a73 to your computer and use it in GitHub Desktop.
Save kirbysayshi/4b4576d23b271d93e71c33544acb5a73 to your computer and use it in GitHub Desktop.
all the other ones on the internet either don't work, or only delete local tracking branches. If you have squash+merge enabled for a repo, those techniques won't work!
git fetch -p;
git branch | grep -v master | while read line; do
if git branch -r | grep -q -F $line;
then
echo not deleting $line;
else echo git branch -d $line;
fi;
done;
git fetch -p; git branch | grep -v master | while read line; do if git branch -r | grep -q -F $line; then echo not deleting $line; else echo git branch -d $line; fi; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment