mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
19 lines
485 B
Bash
Executable file
19 lines
485 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
targetBranch=$(git rev-parse --abbrev-ref HEAD)
|
|
else
|
|
targetBranch=$1
|
|
git checkout "$targetBranch"
|
|
fi
|
|
|
|
git for-each-ref refs/heads/ "--format=%(refname:short)" | while read -r branch; do
|
|
mergeBase=$(git merge-base "$targetBranch" "$branch")
|
|
|
|
if [[ $(git cherry $targetBranch $(git commit-tree $(git rev-parse $branch\^{tree}) -p $mergeBase -m _)) == "-"* ]]; then
|
|
git branch -D "$branch"
|
|
fi
|
|
done
|