~cedric

it's something ¯\_(ツ)_/¯

Remove git branches older than X months

November 22, 2019 — Cédric Dekimpe

For the example, we’re deleting merged branches older than 3 months :

for k in $(git branch --sort=committerdate --remote --merged | grep -o -P "(?<=origin\/)[^ ]+"); do if [[ ! $(git log -1 --since='3 month ago' -s origin/$k) ]]; then git push --delete origin $k fi done