Last active
September 22, 2020 01:38
-
-
Save sbmadhav/0828d878a991ea79efc2539bbf7a0dde to your computer and use it in GitHub Desktop.
Delete git branches that did not receive any commits in the last two months
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/bash | |
for k in $(git branch -r | sed /\*/d); do | |
if [ -z "$(git log -1 --since='2 months' -s $k)" ]; then | |
branch_name_with_no_origin=$(echo $k | sed -e "s/origin\///") | |
# echo deleting branch: $branch_name_with_no_origin | |
git push origin --no-verify --delete $branch_name_with_no_origin | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment