1 hour ago · Tech · hide · 0 comments

git log has an --author option to limit the output to commits from matching authors: $ git log --author=<pattern> But there’s no option to invert the filter and show commits from all authors except those matching a pattern. Instead, you can build the negation into the pattern itself, using a regular expression with a negative lookahead, enabled with the --perl-regexp option: $ git log --author='^((?!<pattern>).)*$' --perl-regexp A breakdown of the regular expression: ^ matches the start of the author line, which contains both the author’s name and email address. (?!<pattern>) is a negative lookahead: it fails the match if <pattern> matches at the current position, without consuming any characters. . matches any single character. The wrapping (…)* repeats the previous two steps as many times as possible, applying the lookahead at every position in the line. $ matches the end of the line. The overall effect is to match commits where the author line does not contain <pattern> at any…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.