From 564e79611ac6ee33d25e1e9221d318db3d512c96 Mon Sep 17 00:00:00 2001 From: Alan Norton Date: Fri, 1 Nov 2024 13:11:30 -0400 Subject: [PATCH] git everybody-out --- .gitconfig | 1 + .githelpers | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/.gitconfig b/.gitconfig index 98d5750..6111e49 100644 --- a/.gitconfig +++ b/.gitconfig @@ -97,6 +97,7 @@ broom = "!. ~/.githelpers && delete_remoteless_branches_interactive" spring-cleaning = "!. ~/.githelpers && delete_all_my_branches_interactive" + everybody-out = "!. ~/.githelpers && delete_all_others_local_branches" nuke = "!git reset --hard HEAD && git clean -fd" diff --git a/.githelpers b/.githelpers index 7a64e53..18225b6 100644 --- a/.githelpers +++ b/.githelpers @@ -116,6 +116,15 @@ delete_all_my_branches_interactive(){ done } +# Delete all non-personally-prefixed non-primary branches. +delete_all_others_local_branches(){ + for branch in $(git branch | grep '/' | grep -v 'aln\|anorton\/'); do + printf "Delete $branch? "; + read ans; + [[ "$ans" == "y" ]] && git branch -D $branch + done +} + # Accepts a sed substituion (e.g., s/foo/bar/) and applies it to the current branch, also unsetting the upstream branch. rename_branch_regex(){ if [ -z "$1" ]; then