-
-
Save phivh/746c7764cc1fc375d3c2177c63cd3a03 to your computer and use it in GitHub Desktop.
Delete all local branch that has not received any commits for a while
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 | |
date=$1 | |
delete_local_branch () { | |
if [[ "$date" == "" ]]; then | |
echo "Missing date!" | |
exit | |
fi | |
for k in $(git branch | sed /\*/d); do | |
if [ -z "$(git log -1 --since='$date' -s $k)" ]; then | |
local_branch_name=$(echo $k | sed -e "s/origin\///") | |
echo deleting branch: $local_branch_name | |
git branch -d $local_branch_name | |
fi | |
done | |
} | |
delete_local_branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Somehow, using this script directly