Created
July 24, 2018 14:06
-
-
Save kevinquillen/2e50ebdc0e08d346a9358b0bb9757c28 to your computer and use it in GitHub Desktop.
Blow away branches that are older than a year.
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/sh | |
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do | |
if [[ "$(git log $branch --since "12 months ago" | wc -l)" -eq 0 ]]; then | |
# I have to do this because "git log" for me returns current directory contents... not sure why yet. | |
if [[ ${branch} == *".sh" ]]; then | |
continue | |
fi | |
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///') | |
git branch -d $local_branch_name | |
git push origin --delete $local_branch_name | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment