Can gitk show all commits EXCEPT those by a given author?
Asked Answered
D

2

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?

Deberadeberry answered 13/6, 2011 at 17:31 Comment(2)
Related: #3448500Ideal
I tried the method linked here without success: #3448500Deberadeberry
R
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

Roger answered 30/9, 2016 at 14:46 Comment(3)
This didn't work for me. I tried this on a Windows machine.Guyenne
@Guyenne 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.Roger
this does not work for me. On linuxForeword
U
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])

Ullrich answered 13/6, 2011 at 19:55 Comment(1)
This doesn't work, since gitk is set up to ignore the --no-walk flagCarbazole

© 2022 - 2024 — McMap. All rights reserved.