Search code examples
gitbranchgit-logauthorgit-history

Filter git log by author or branch


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 ?


Solution

  • 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