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.
The git grep version will only search in files tracked by git, whereas the grep version will search everything in the directory. So far so similar; either one could be better depending on what you want to achieve.
Graph all git branchesDevelopers can see all branches in the graph with the –all switch. Also, in most situations, the –decorate switch will provide all the supplemental information in a formatted and nicely color-coded way.
This will be possible with Git 2.4+ (Q2 2015): see commit 22dfa8a by Christoph Junghans (junghans
):
log
: teach--invert-grep
option
"
git log --grep=<string>
" shows only commits with messages that match the given string, but sometimes it is useful to be able to show only commits that do not have certain messages (e.g. "show me ones that are not FIXUP commits").Originally, we had the
invert-grep
flag ingrep_opt
, but because "git grep --invert-grep
" does not make sense except in conjunction with "--files-with-matches
", which is already covered by "--files-without-matches
", it was moved it to revisions structure.
To have the flag there expresses the function to the feature better.When the newly inserted two tests run, the history would have commits with messages "
initial
", "second
", "third
", "fourth
", "fifth
", "sixth
" and "Second
", committed in this order.
The commits that does not match either "th
" or "Sec
" is "second
" and "initial
". For the case insensitive case only "initial
" matches.--invert-grep
Limit the commits output to ones with log message that do not match the pattern specified with
--grep=<pattern>
.
Example:
I first grep message with "sequencer" in them:
vonc@voncm C:\Users\vonc\prog\git\git > git log -2 --pretty="tformat:%s" --grep=sequencer Merge branch 'js/sequencer-wo-die' sequencer: ensure to release the lock when we could not read the index
If I want messages with no sequencer:
> git log -2 --pretty="tformat:%s" --grep=sequencer --invert-grep Second batch for 2.11 Merge branch 'js/git-gui-commit-gpgsign'
Warning: this inverts only patterns specified by --grep
.
It will not invert anymore header matches, like --author
, --committer
, starting Git 2.35+ (Q1 2022).
See an example in "equivalence of: git log --exclude-author?
".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With