dotfiles/local/bin/git-sweep

7 lines
212 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
git branch --merged "$([[ "${1}" != "-f" ]] && git rev-parse HEAD)" |
grep -Ev '(^\*|^\s*(main|master|develop)$)' |
while read -r branch_name; do
git branch -d "${branch_name}"
done