Last active
February 8, 2017 20:16
-
-
Save niallsmart/047f8281d52c7b8ae9f66e9a7bbe1630 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# generates a script that will delete merged branches | |
# that were last updated prior to 2016-10-01 | |
# | |
function list_ancient_branches() { | |
git branch -r --merged | \ | |
grep -v HEAD | \ | |
xargs -n1 -I {} git show -s --format="%cI %h {}" {} | \ | |
egrep -v '^(2017|2016-1)' | |
} | |
list_ancient_branches | while read date sha branch; do | |
echo "# $date $branch $sha" | |
echo git push origin --delete ${branch/origin\/} | |
echo | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment