Skip to content

Instantly share code, notes, and snippets.

@mattbostock
Last active December 17, 2018 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbostock/31b56bf9dc6e7f51e449a4d72af05f1e to your computer and use it in GitHub Desktop.
Save mattbostock/31b56bf9dc6e7f51e449a4d72af05f1e to your computer and use it in GitHub Desktop.
Prune Git branches that were merged by rebasing in GitHub
#!/usr/bin/env bash
set -eo pipefail
# Not thoroughly tested, please use with caution! Try with 'echo {}' first to confirm it works for you.
#
# exec git for-each-ref refs/heads/ "--format=%(refname:short)" | grep -v master | xargs -P 4 -I {} bash -c "( ! git cherry master {} | grep -q '^[^-]' ) && git branch -D {}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment