Reputation: 321
I have multiple repositories with a lots of old branches that were never deleted.
Is there a way to search all branches that were not updated for a specified amount of time ?
I also want to add in that search if possible, branches that doesn't have commits ahead of master, to make sure nothing important is deleted.
At that point, I don't care if they were merged or not,
Upvotes: 1
Views: 924
Reputation: 142064
You can do what ever you wish.
Here is a sample script which will print out all the branches with their last commit date (should be on a single line)
for ref in $(git branch);
do git log -n1 $ref
--pretty=format:"%Cgreen%an%Creset %C(yellow)%d%Creset %C(bold blue)%cr%Creset%n" ;
done | cat | sort -n -k1,1
It will print out all branches in a cool way so you can echo the $ref to file and delete them
Upvotes: 2