It seems like 1836 branches exist in one of the company's repos and I've been given a task to first display and then delete all branches that have not been committed to for 6 months.
I found this SO question and tried running (with both --until and --before and "month"):
#!/bin/bash
branches_to_delete_count=0
for k in $(git branch -a | sed /\*/d); do
if [ -n "$(git log -1 --before='6 month ago' -s $k)" ]; then
echo "NOT REALLY DELETING, git branch -D $k"
fi
((branches_to_delete_count=branches_to_delete_count+1))
done
echo "Found $branches_to_delete_count branches to delete!"
But to no avail, I get the same number of branches to delete each time which is 1836.
What am I doing wrong? How can I list all branches that haven't been committed for more than 6 months?