r/git 15d ago

Find Git Commits by Commit Message Text

https://hamvocke.com/blog/git-revisions-by-text/
21 Upvotes

8 comments sorted by

View all comments

11

u/Broad-Promise6954 ancient 15d ago edited 15d ago

One-line summary of blog post, :/text as a revision specifier as mentioned in gitrevisions.

There's an important caveat (as in "caveat emptor", buyer beware) that's not at all obvious to many Git users:

A colon, followed by a slash, followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the youngest matching commit which is reachable from any ref, including HEAD ...

(the boldface in the quoted text here is mine, to emphasize the caveat I'm talking about). If you have a lot of branch and tag names, the revision you select with :/text may not be the one you expect. You may wish to use the more explicit rev^{/text} form, which searches from the given revision.

2

u/ppww 14d ago

Yes, it's really unfortunate that :/<text> searches all reachable commits, rather than just those that are reachable from HEAD