Skip to content

Instantly share code, notes, and snippets.

View mikedidomizio's full-sized avatar

Mike DiDomizio mikedidomizio

View GitHub Profile
@mikedidomizio
mikedidomizio / delete_branches_older_than.sh
Created February 17, 2021 12:25 — forked from AvnerCohen/delete_branches_older_than.sh
Script to delete branches older than 6 months old, ignore local vs remote errors.
#!/bin/sh
ECHO='echo '
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
if [[ "$(git log $branch --since "6 months ago" | wc -l)" -eq 0 ]]; then
if [[ "$DRY_RUN" = "false" ]]; then
ECHO=""
fi
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git branch -d $local_branch_name