kushagra jaiswal kushagra jaiswal - 1 year ago 110
Git Question

Search git log using a comment

I check my git logs using

git log --stat
which shows me all the commits and the files that were changed in those commits.

Now there is a commit that was made a long time ago, I remember a part of the commit message such that when I do
git log --stat | grep 'message text'
the log shows only the commit messages in which 'message text' exists.

I, however need to see at least the commit id along with the grep results. How do I achieve this?

Answer Source

Try using --oneline :

git log --oneline | grep -F 'message text'

Otherwise, pipe your result through less, and searching using less:

git log | less
/message text