• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Twitter GitHub
You are here: Home / Dev Tips / Git Target Commit by Message

Git Target Commit by Message

Last updated on June 11, 2018 by Sal Ferrarello

There are lots of ways to target a git commit, e.g.

git show HEAD~1

One way that I often forget to use (but really like it when I remember) is targeting a specific git commit by the commit message, e.g.

git show :/Fix

will target the most recent commit with a message that includes the string “Fix”.

If you want to include a space, use quotes, e.g.

git show :/"Fix silly"

The string matching is actually done using regular expressions, so you can do something like

git show :/^Fix

to target the most recent commit that begins with “Fix”

Git Documentation

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

TwitterFacebookLinkedInEmailReddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Solution Tagged With: command line, Git

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2021 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in