Skip to content

Instantly share code, notes, and snippets.

@oafridi
Created August 12, 2020 21:43
Show Gist options
  • Save oafridi/4129b50d351ee6c2f4d3e0b2ea5291f2 to your computer and use it in GitHub Desktop.
Save oafridi/4129b50d351ee6c2f4d3e0b2ea5291f2 to your computer and use it in GitHub Desktop.
prune branches
DRY_RUN='TRUE'
ECHO='echo'
for branch in `git branch -r --merged | grep -v HEAD`; do
if [[ "$(git log $branch --since "3 months ago" | wc -l)" -eq 0 ]]; then
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git push origin --delete $local_branch_name
fi
done > dry_run.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment