It is fairly easy to list branches sorted by date. For example, the following command gives me a nice columnar output showing relative date, branch name, and commiter.
git for-each-ref --sort='-committerdate:iso8601' --format='%(committerdate:relative)|%(refname:short)|%(committername)' refs/remotes/ | column -s '|' -t
But what about filtering by date? What if I want to only see branches from the last 2 months? Is there any straightforward way to do that?
What about filtering out all branches that are already merged into main
?
Ideally I would keep the ability to sort by date, but the 2 filters are more important than the sorting.
Also I'd love to be able to use all stored dates and include the branch if any of the dates are recent. I believe these include authordate
, commiterdate
, creatordate
, and taggerdate
. That might be over complicated, though, and is not essential.
Updates:
- Apparently filtering by merge status is easy with
--no-merged=main
. - It looks like filtering by date might be possible with
%(if)...%(then)...%(else)...%(end)
, but I haven't worked out the details yet.