Skip to content

Commit

Permalink
return of the rat
Browse files Browse the repository at this point in the history
  • Loading branch information
nonrational committed Nov 14, 2024
1 parent e4c3166 commit c2c787e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .githelpers
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,21 @@ switch_wildcard() {
}

# Delete local-only branches with confirmation.
delete_remoteless_branches_interactive(){
/usr/bin/python3 $HOME/bin/git-broom.py
delete_remoteless_branches_interactive() {
git fetch origin --prune --tags -f

main_branch=$(remote_origin_primary_branch)
remote_branches=$(git branch --remote | grep "origin" | grep -v "HEAD" | cut -c10- | egrep -v "^${main_branch}$")
local_branches=$(git branch | grep -v "HEAD" | cut -c3- | egrep -v "^${main_branch}$")

for local_branch in $local_branches; do
if ! echo "$remote_branches" | grep -q "$local_branch"; then
read -p "Delete $local_branch? (y/n): " response
if [[ $response =~ ^[Yy] ]]; then
git branch -D "$local_branch"
fi
fi
done
}

# Delete all personally-prefixed non-primary branches with confirmation.
Expand Down

0 comments on commit c2c787e

Please sign in to comment.