Created
January 24, 2024 21:22
-
-
Save mdzhang/5f31f57e91b466cb5b7eab921851dd75 to your computer and use it in GitHub Desktop.
delete old git branches
This file contains hidden or 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 | |
git fetch --prune | |
for k in $(git branch -r --sort=committerdate | head -n 100); do | |
if [ -z "$(git log -1 --after='2 years ago' -s $k)" ]; then | |
br=$(echo $k | cut -d'/' -f2-) | |
echo "Removing $br" | |
echo "--" | |
echo "Summary:" | |
git log -n 1 --pretty=format:"%h %an, %ar : %s" $k | |
echo "--" | |
git push origin -d $br | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment