Created
December 10, 2015 09:11
-
-
Save mciuba/44159c1d7621093af9bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
#modified script from: http://stackoverflow.com/a/5396755/2128900 | |
# Git lets you use very readable time formats! | |
cutoff_time="1 week ago" | |
# other examples: | |
# cutoff_time="July 23, 2010" | |
# cutoff_time="yesterday" | |
git for-each-ref refs/heads --format='%(refname)' | egrep -v 'master|dev' | | |
while read branch; do | |
git reflog expire --expire="$cutoff_time" $branch | |
if [ "$(git reflog show -1 $branch | wc -l)" -eq 0 ]; then | |
git branch -D ${branch#refs/heads/} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment