I want to use git log to show all commits that do not match a given pattern. I know I can use the following to show all commits that do match a pattern:
git log --grep=<pattern>
How do I invert the sense of matching?
I am trying to ignore commits that have “bumped to version …” in the message.
EDIT: I want my final output to be pretty verbose. e.g. git log --pretty --stat. So output from git log --format=oneline won’t work for me.
Generate a list of all commits, subtract those whose log messages contain the offending pattern, and feed the result to
git logwith your desired options. In the final stage, a couple of options togit logare handy:You can do it with a single pipeline and process substitution.
If you don’t want to use bash, you could do it with Perl.
Assuming one of the above is in your PATH as
git-log-vgrepand with a history of the formwe could say
to get Z, Y, W, and V.
You can also log other branches, so
gives D, C, B, and V; and
yields just D.
One limitation of the above implementations is if you use a pattern that matches all commits, e.g.,
.or^, then you’ll get HEAD. This is howgit logworks: