Created
November 6, 2024 21:08
-
-
Save inxilpro/213ab8c0f424df5c60211bc59bc404d1 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/bash | |
now=$(date +%s) | |
two_years_in_seconds=$((2 * 365 * 24 * 60 * 60)) | |
cutoff_date=$((now - two_years_in_seconds)) | |
git for-each-ref --format '%(authordate:iso) %(refname)' refs/heads | while read line; do | |
authordate="${line%% refs/heads/*}" | |
authordate_unix=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$authordate" +%s) | |
refname="${line##* refs/heads/}" | |
if [ $cutoff_date -gt $authordate_unix ]; then | |
echo "git branch -D ${refname} # updated ${authordate}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment