Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. date="2020-01-01T01:00:00"
  2. DRY_RUN=1
  3. branches=
  4.  
  5. for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
  6.   if [[ "$(git log --since=$date $branch | wc -l)" -eq 0 ]]; then
  7.     if [[ "$branch" =~ "origin/" ]]; then
  8.       if [[ -z $branches ]]; then
  9.         branches=$(echo "$branch" | sed 's/^origin\///')
  10.       else
  11.         branches="$branches "$(echo "$branch" | sed 's/^origin\///')
  12.       fi
  13.     fi
  14.   fi
  15. done
  16. if [[ ! -z $branches ]]; then
  17.   if [[ "$DRY_RUN" -eq 1 ]]; then
  18.     echo git branch -D $branches
  19.     echo git push --delete origin $branches
  20.   else
  21.     git branch -D $branches
  22.     git push --delete origin $branches
  23.    
  24.     # clean up locally
  25.     git remote prune origin
  26.   fi
  27. fi
  28. Echo "End"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement