How to invert `git log --grep=` or How to show git logs that don't match a pattern

前端 未结 8 897
旧巷少年郎
旧巷少年郎 2020-12-02 22:34

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:

8条回答
  •  暖寄归人
    2020-12-02 23:20

    As far as I can tell, this is not possible to do directly with a single command line; you'd have to do something like Justin Lilly suggests and then run 'git log' on the resulting list of hashes, e.g.,

    git log --format="%h" | grep -v `git log -1 --grep="bumped to version" --format="%h"` > good-hashes
    for h in `cat good-hashes`; do
        PAGER=cat git log -1 --pretty --stat $h
    done
    

    should do the trick.

提交回复
热议问题