Last active
July 8, 2019 09:02
-
-
Save ziggahunhow/21625a7f4d2c41a3c5bbf597dff42f4c to your computer and use it in GitHub Desktop.
Remove old git remote branches
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 | |
# run with caution! Change the date on line 4 | |
for k in $(git branch -r | sed /\*/d); do | |
if [ -z "$(git log -1 --since='2 month ago' -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 --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