Last active
February 24, 2026 04:20
-
-
Save mattn/06594c6d59e178333e8024306ae7079f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [alias] | |
| sweep-branch = "!git for-each-ref refs/heads/ --format=\"%(refname:short)\" | while read branch; do [ \"$branch\" = main ] || [ \"$branch\" = master ] && continue; git rev-parse --abbrev-ref HEAD | grep -qx \"$branch\" && continue; mergeBase=$(git merge-base main \"$branch\" 2>/dev/null) || continue; treeCommit=$(git commit-tree \"$(git rev-parse \"$branch^{tree}\")\" -p \"$mergeBase\" -m _); cherry=$(git cherry main \"$treeCommit\" 2>/dev/null); case \"$cherry\" in \"-\"*) git branch -D \"$branch\" ;; esac; done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment