Skip to content

Instantly share code, notes, and snippets.

@sameerkumar18
Last active November 2, 2019 12:10
Show Gist options
  • Save sameerkumar18/4cbd5b16f0800d42213253a627e62d05 to your computer and use it in GitHub Desktop.
Save sameerkumar18/4cbd5b16f0800d42213253a627e62d05 to your computer and use it in GitHub Desktop.
Remove all merged branches older than X months
#!/bin/sh
for k in $(git branch | sed /\*/d); do
if [ -n "$(git log -1 --before='4 months ago' -s $k)" ]; then
git branch -d $k
git push origin --delete $k
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment