Is there any way to get the SHA of a commit from its message?

前端 未结 3 2398
一整个雨季
一整个雨季 2021-02-19 23:19

When doing a git tag, I\'m not always great at remembering if HEAD~6 (for example) is inclusive or exclusive.

Given that most of my commits are prefixed wi

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-20 00:03

    Try

    git rev-list --grep='message excerpt' HEAD
    

    This will only list commits that are ancestors of HEAD. If you wanted to search all commits in the repository (including those that are not ancestors of HEAD), I'm not sure how to do that other than by manually going through all the branch heads manually and running this command. (There's probably a way, I just don't know what it might be)

提交回复
热议问题