git-prune-local 466 B

12345678910111213141516171819202122
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. self=$(git config --get user.name)
  4. head=$(git head)
  5. for branch in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
  6. if [ "$branch" == "$head" ]; then
  7. continue
  8. fi
  9. if git merge-base --is-ancestor "$branch" origin/HEAD; then
  10. git branch -d "$branch"
  11. continue
  12. fi
  13. author=$(git show --no-patch --pretty='%an' "$branch")
  14. if [ "$author" != "$self" ]; then
  15. git branch -D "$branch"
  16. fi
  17. done