Skip to content

Instantly share code, notes, and snippets.

@brycebaril
Forked from cxreg/gist:5042722
Created February 26, 2013 23:41
Show Gist options
  • Save brycebaril/5043444 to your computer and use it in GitHub Desktop.
Save brycebaril/5043444 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ $1 != "-f" ]]; then
echo "### Dry-run mode, specify -f to actually perform deletes.";
fi;
for branch in $(git branch -r --merged origin/master | grep '\<origin/' | grep -v '\<origin/master\>');
do
if [[ -z $(git rev-list $branch --since '1 month') ]]; then
name=$(echo $branch | sed 's/^origin\///');
if [[ $1 = "-f" ]]; then
git push --delete origin "$name";
else
echo git push --delete origin "$name";
fi;
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment