Print commit message of a given commit in git

后端 未结 6 1928
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 10:10

I need a plumbing command to print the commit message of one given commit - nothing more, nothing less.

6条回答
  •  抹茶落季
    2020-11-27 10:56

    It's not "plumbing", but it'll do exactly what you want:

    $ git log --format=%B -n 1 
    

    If you absolutely need a "plumbing" command (not sure why that's a requirement), you can use rev-list:

    $ git rev-list --format=%B --max-count=1 
    

    Although rev-list will also print out the commit sha (on the first line) in addition to the commit message.

提交回复
热议问题