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