Question

I want to use gitk to view all commits except those by a given author. Something like the following:

gitk --author=!joe

Is this possible?

Was it helpful?

Solution

I don't think there is a terribly easy way to do it--

If you have perl or something similar, you can piece together a solution:

  1. Get the list of commits you want to exclude and put them in a hash: git rev-list [refs] --author="[author pattern]"

  2. Get the list of commits you want to show: git rev-list [refs]

  3. Subtract the items in the hash from the commits you want to show

  4. Show the commits you do want to show: gitk --no-walk [output of subtraction]

You could write something in perl/python/ruby pretty easily to do 1-3, and then just do

gitk --no-walk $(drop-author.pl [refs] [author-pattern])

OTHER TIPS

From the command line:

gitk --perl-regexp --author='^(?!joe)'

To exclude commits by several authors:

gitk --perl-regexp --author='^(?!jack|jill)'

Explanation: (?!whatever) is a (perl-style) look-ahead regular expression: it matches a position not followed by whatever. We anchor it to the beginning of the Author field by the "beginning of string" regexp ^.

Or run gitk --perl-regexp and then in the gitk menu, select View -> New View (or Shift+F4 for short) and write ^(?!joe) into the "Author" field.

If you do not want to always have to type gitk --perl-regexp, you can set up git to globally use perl regular expressions by running

git config --global grep.patternType perl

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top