Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4258854
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:42:18+00:00 2026-05-21T05:42:18+00:00

I want to use git log to show all commits that do not match

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:42:18+00:00Added an answer on May 21, 2026 at 5:42 am

    Generate a list of all commits, subtract those whose log messages contain the offending pattern, and feed the result to git log with your desired options. In the final stage, a couple of options to git log are handy:

    --stdin
    In addition to the commit listed on the command line, read them from the standard input.

    --no-walk
    Only show the given revs, but do not traverse their ancestors.

    You can do it with a single pipeline and process substitution.

    #! /bin/bash
    
    if (( $# < 1 )); then
      echo >&2 "Usage: $0 pattern [<since>..<until>]"
      exit 1
    fi
    
    pattern=$1
    shift
    
    git log --format=%H $@ |
      grep -v -f <(git log --format=%H "--grep=$pattern" $@) |
      git log --pretty --stat --stdin --no-walk
    

    If you don’t want to use bash, you could do it with Perl.

    #! /usr/bin/env perl
    
    use strict;
    use warnings;
    no warnings "exec";
    
    sub usage { "Usage: $0 pattern\n" }
    
    sub commits_to_omit {
      my($pattern) = @_;
    
      open my $fh, "-|", "git", "log", "--grep=$pattern", "--format=%H", @ARGV
        or die "$0: exec: $!";
      my %omit = map +($_ => 1), <$fh>;
      %omit;
    }
    
    die usage unless @ARGV >= 1;
    my $pattern = shift;
    
    my %omit = commits_to_omit $pattern;
    
    open my $all, "-|", "git", "log", "--format=%H", @ARGV
      or die "$0: exec: $!";
    
    open my $out, "|-", "git", "log", "--pretty", "--stat", "--stdin", "--no-walk"
      or die "$0: exec: $!";
    
    while (<$all>) {
      print $out $_ unless $omit{$_};
    }
    

    Assuming one of the above is in your PATH as git-log-vgrep and with a history of the form

    $ git lola
    * b0f2a28 (tmp, feature1) D
    * 68f87b0 C
    * d311c65 B
    * a092126 A
    | * 83052e6 (HEAD, origin/master, master) Z
    | * 90c3d28 Y
    | * 4165a42 X
    | * 37844cb W
    |/  
    * f8ba9ea V

    we could say

    $ git log-vgrep X

    to get Z, Y, W, and V.

    You can also log other branches, so

    $ git log-vgrep A tmp

    gives D, C, B, and V; and

    $ git log-vgrep C tmp~2..tmp

    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 how git log works:

    $ git log --stdin --no-walk --pretty=oneline </dev/null
    83052e62f0dc1c6ddfc1aff3463504a4bf23e3c4 Z
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use git log, but I find it can only list logs under current
I want to use the git hash of files as asset id. For that
I want to use git as a local repository against a remote SVN repository.
I want to use git to allow me to work on several features in
Below is my stored procedure. I want use stored procedure select all row of
I want to use the MultipleLookupField control in a web page that will run
I'm using Git wrong. I want to use it right. Here's what I've got:
I found a post-receive hook for Git after some googling that I use to
I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom
I want to use Powershell to write some utilities, leveraging our own .NET components

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.