Filter git log by author or branch
Asked Answered
M

1

6

In my workflow I'm usually only interested in my own branches and some specific branches like staging or master and would like my git log to reflect that. I've come up with this command :

git log --branches=staging* --author=my_name

The problem is that the author and branches filters seem to linked with the logical operator and, meaning that I can either see all my branches or staging, but not both at the same time.

In other words, I'd like to see only commits where I'm the author AND all the commits of the branch named staging branch (regardless of the authors), with one single command.

Is there a way to achieve this ?

Mcmann answered 8/12, 2018 at 10:9 Comment(2)
Not clear what you askingDonough
@Donough I just added a paragraph to rephrase my question. Is it better ?Mcmann
C
5

Git will take commit ids from stdin, it's not limited to any precanned set of construction operators and there's no reason to duplicate arbitrary selection logic when the results can be achieved with existing tools.

(git rev-list --branches=staging*;git rev-list --all --author=my_name) \
| git log --stdin --no-walk --oneline
Crib answered 8/12, 2018 at 13:47 Comment(1)
Thanks ! Exactly what I needed. I actually use the --graph option to represent the repository tree, so I ended up replacing --no-walk by --graph (they are mutually exclusive) : (git rev-list --branches=staging*;git rev-list --all --author=my_name) | git log --stdin --graph --oneline.Mcmann

© 2022 - 2024 — McMap. All rights reserved.