Last active
September 1, 2016 17:06
-
-
Save komuw/3defd321f9b3ab751906fd201bb1eb2b to your computer and use it in GitHub Desktop.
delete branches that are older than x days
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
| # delete branches that are older than x days | |
| # this will delete branches that havent received any commits that are newer than Aug 10, 2016 | |
| # see this answer for a bit more detail: http://stackoverflow.com/questions/10325599/delete-all-branches-that-are-more-than-x-days-weeks-old/39277210#39277210 | |
| for k in $(git branch -r | sed /\*/d); do | |
| if [ -z "$(git log -1 --since='Aug 10, 2016' -s $k)" ]; then | |
| branchnew=$(echo $k | sed -e "s/origin\///") | |
| echo deleting branch: $branchnew | |
| git push origin --delete $branchnew | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment