Add a full script version of git-sweep

with a smidge more resilience
This commit is contained in:
Dan Buch 2023-02-28 16:43:49 -05:00
parent 0390fdb43d
commit 5ddd23b1d0
Signed by: meatballhat
GPG Key ID: A12F782281063434
2 changed files with 6 additions and 1 deletions

View File

@ -59,7 +59,6 @@
[alias]
hug = blame
lograph = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
sweep = !git branch --merged $([[ $1 != \"-f\" ]] && git rev-parse master) | egrep -v \"(^\\*|^\\s*(master|develop)$)\" | xargs git branch -d
[commit]
template = ~/.gittemplate

6
local/bin/git-sweep Executable file
View File

@ -0,0 +1,6 @@
#!/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