Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 877
Scentle5S Avatar asked Dec 08 '18 10:12

Scentle5S


People also ask

Does git filter branch rewrite history?

Lets you rewrite Git revision history by rewriting the branches mentioned in the <rev-list options>, applying custom filters on each revision. Those filters can modify each tree (e.g. removing a file or running a perl rewrite on all files) or information about each commit.

Is git log in chronological order?

By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first.

How do I search git logs?

Line Log Search Simply run git log with the -L option, and it will show you the history of a function or line of code in your codebase.

Which command is used to check last 5 commits by a particular author in git?

The git shortlog command is a special version of git log intended for creating release announcements. It groups each commit by author and displays the first line of each commit message.


1 Answers

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
like image 100
jthill Avatar answered Oct 05 '22 07:10

jthill