0

I tried the below to list out all remote branches in GitHub but even though I'm specifying the 1 year 'since' parameter it still shows all remote branches:

git branch -r --merged | grep -v "master" | xargs -I {} bash -c 'if [ `git log --since="1 year ago" -s -n1 --pretty=format:%ct {}` ]; then echo {}; fi'
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
KristiLuna
  • 1,601
  • 2
  • 18
  • 52
  • My advice is to go with [`git for-each-ref`](https://stackoverflow.com/a/5188364/7976758). Start with something like `git for-each-ref --format='%(committerdate:short) %(refname)' --merged=master --sort=committerdate refs/remotes` – phd Mar 07 '23 at 17:46
  • @phd where would I include the 'since' parameter? – KristiLuna Mar 07 '23 at 17:50
  • It's not the final solution. The output of `git for-each-ref` needs to be processed further. In `--format=` I put the committer date in the 1st column and sort by the date. Interpret the column and cut before some date. – phd Mar 07 '23 at 17:58
  • 1
    See https://stackoverflow.com/a/62576320/86072 (and the insightful comment by @phd on that question ;) ) – LeGEC Mar 07 '23 at 19:11

0 Answers0