Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Git commit hash from commit message

Tags:

git

Is it possible to get the hash of a commit from a commit message?

I ran the following git log | grep tap and got a list of commit messages only, no hashes.

I need to cherry-pick a few of the listed commits, but don't want to manually search for them all to find the commit hashes.

like image 209
some_id Avatar asked Mar 07 '16 06:03

some_id


1 Answers

Yep you can.

You have minor mistake in your command:
The correct command is to use the --grep as flag to the log and not as a unix command after the pipe |

git log --grep=".. any text you need to find ..."

enter image description here


git log --grep=<pattern>

Limit the commits output to ones with log message that matches the specified pattern (regular expression).

With more than one --grep=<pattern>, commits whose message matches any of the given patterns are chosen (but see --all-match).

When --show-notes is in effect, the message from the notes is matched as if it were part of the log message.

like image 85
CodeWizard Avatar answered Oct 21 '22 23:10

CodeWizard