Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- date="2020-01-01T01:00:00"
- DRY_RUN=1
- branches=
- for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
- if [[ "$(git log --since=$date $branch | wc -l)" -eq 0 ]]; then
- if [[ "$branch" =~ "origin/" ]]; then
- if [[ -z $branches ]]; then
- branches=$(echo "$branch" | sed 's/^origin\///')
- else
- branches="$branches "$(echo "$branch" | sed 's/^origin\///')
- fi
- fi
- fi
- done
- if [[ ! -z $branches ]]; then
- if [[ "$DRY_RUN" -eq 1 ]]; then
- echo git branch -D $branches
- echo git push --delete origin $branches
- else
- git branch -D $branches
- git push --delete origin $branches
- # clean up locally
- git remote prune origin
- fi
- fi
- Echo "End"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement