Reputation: 3114
I want to know the commit ID (hash) of a specific commit message. More often than not, the commit message will be unique hence there should be no case of multiple commits with same message.
Following command gives the complete detail about the commit, but i'm interested only in the commit-id (Hash). How can i know it ?
Input:
git log --grep="....commit message that you want to search..."
Output:
commit a5s6d7f8g9cde4100ce92c87c3cff83e8112345de
Author: Authors Name <[email protected]>
Date: Tue Feb 2 09:22:29 2048 +0000
commit-message: This is the message that i search to get commit hash
Expected Output:
a5s6d7f8g9cde4100ce92c87c3cff83e8112345de
Upvotes: 2
Views: 2739
Reputation: 433
Add --format='%H'
git log --grep="....commit message that you want to search..." --format='%H'
More info: https://git-scm.com/docs/pretty-formats
Upvotes: 5