6

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?

David Hansen
  • 2,857
  • 2
  • 21
  • 19
  • Related: http://stackoverflow.com/questions/3448000/list-commits-made-by-others-i-e-not-me – Dogbert Jun 13 '11 at 17:38
  • I tried the method linked here without success: http://stackoverflow.com/questions/3448000/list-commits-made-by-others-i-e-not-me – David Hansen Jun 13 '11 at 19:03

2 Answers2

11

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

Ansa211
  • 462
  • 5
  • 9
  • This didn't work for me. I tried this on a Windows machine. – Josh Jun 15 '18 at 16:56
  • 1
    @Josh You're right, I did not realize that I have a global setting for perl-type regular expressions which is necessary for this to work. I edited the answer. – Ansa211 Jun 18 '18 at 07:06
1

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])

antlersoft
  • 14,636
  • 4
  • 35
  • 55