Last active
February 1, 2022 16:01
-
-
Save geebru/16bfe13641fdabf8b6e094f6850a60a5 to your computer and use it in GitHub Desktop.
A shell script to check for all merged branches (local/remote) older than 6 months and delete them.
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/sh | |
for branch in $(git branch -r --merged | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'develop$\|develop-hybrid$\|master$\|IPM-\|4\.'); do | |
if [[ "$(git log $branch --since "4 months ago" | wc -l)" -eq 0 ]]; then | |
local_branch_name=$(echo "$branch" | sed 's/origin\///') | |
echo 'Deleting: ' $local_branch_name | |
#git push origin :$local_branch_name | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment