1

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:

  1. Apparently filtering by merge status is easy with --no-merged=main.
  2. It looks like filtering by date might be possible with %(if)...%(then)...%(else)...%(end), but I haven't worked out the details yet.
iconoclast
  • 21,213
  • 15
  • 102
  • 138
  • https://stackoverflow.com/a/70456463/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+for-each-ref+filter+date – phd Aug 09 '22 at 19:41

0 Answers0