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.
As with thebriguy's answer, grep also has a -z option to enable it to work with null terminated strings rather than lines. This would then be as simple as inverting the match:
For safety you may want to match within the commit message only. To do this with grep, you need to use pearl expressions to match newlines within the null terminated strings. To skip the header:
Or with colour:
Finally, if using --stat, you could also match the beginning of this output to avoid matching file names containing the commit string. So a full answer to the question would look like:
Note that
grep -P
is described as 'highly experimental' in my man page. It may be better to usepcregrep
instead which uses libpcre, see How to give a pattern for new line in grep?. Althoughgrep -P
works fine for me and I have no idea ifpcregrep
has a -z option or equivalent.get a list of all commits containing your result, then filter out their hashes.