Last active
January 24, 2022 11:08
-
-
Save umardx/b95ab03662bf7c0b7799d5375af649ab to your computer and use it in GitHub Desktop.
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 | |
ECHO='echo ' | |
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$\|main$\|develop$'); do | |
if ! ( [[ -f "$branch" ]] || [[ -d "$branch" ]] ) && [[ "$(git log $branch --since "3 month ago" | wc -l)" -eq 0 ]]; then | |
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 |
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 -x | |
SINCE="2020-09-30" | |
git branch -r --sort=committerdate | sed /\*/d | grep -v "origin/master" | while read BRANCH; do \ | |
if [[ -z "$(git log -1 --date=local --since="${SINCE}" -s ${BRANCH})" ]]; then \ | |
echo "Deleting vranch ${BRANCH#origin\/} that older than ${SINCE}.";\ | |
git push origin --delete "${BRANCH#origin\/}";fi \ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment