QT-DevOps / DevOpsIssues

This Repo will be used to demonstrate the Skills & Questions in DevOps
Apache License 2.0
27 stars 130 forks source link

shell script to delete git branches #1028

Open tarunkumar110695 opened 3 years ago

tarunkumar110695 commented 3 years ago

Below is the script which I'm executing but unable to succeed. the task is delete branch date specific ECHO='echo ' for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do if [[ "$(git log $branch --since "20 Jun 2021" | wc -l)" -eq 0 ]]; then if [[ "$DRY_RUN" = "false" ]]; then ECHO="" fi local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///') $ECHO git branch -d "${local_branch_name}" $ECHO git push origin --delete "${local_branch_name}" fi done WhatsApp Image 2021-06-23 at 11 09 16 WhatsApp Image 2021-06-23 at 11 09 01

tarunkumar110695 commented 3 years ago

Help would be appreciated