Skip to content

Instantly share code, notes, and snippets.

@flaviosilveira
Created September 14, 2015 02:09
Show Gist options
  • Save flaviosilveira/b3508b21e3582f8ae417 to your computer and use it in GitHub Desktop.
Save flaviosilveira/b3508b21e3582f8ae417 to your computer and use it in GitHub Desktop.
Delete Old Branches
#!/bin/sh
date=2015-01-01
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
if [ $(git log $branch --since $date | wc -l) -eq 0 ]; then
# echo "DELETAR $branch"
git push --delete origin $(echo $branch | sed 's/^\s*//' | sed 's/^origin\///')
#else
# echo "NAO $branch"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment