Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kurtz1993/31e9836defa376aa4e229a6573b6c77c to your computer and use it in GitHub Desktop.
Save Kurtz1993/31e9836defa376aa4e229a6573b6c77c to your computer and use it in GitHub Desktop.
#!/bin/bash
ECHO='echo '
git fetch -p
for branch in $(git branch -r | egrep -v "(^\*|main|dev|release)"); do
if [[ "$(git log $branch -1 --since "3 months ago" | wc -l)" -eq 0 ]]; then
local_branch_name=$(echo "$branch" | sed 's/origin\///' | sed 's/remotes\///' | tr '[:upper:]' '[:lower:]')
# $ECHO git branch -d $local_branch_name
git push origin --delete $local_branch_name
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment