Print commit message of a given commit in git

Mark Probst picture Mark Probst · Jul 28, 2010 · Viewed 117.4k times · Source

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

Answer

mipadi picture mipadi · Jul 28, 2010

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

$ git log --format=%B -n 1 <commit>

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 <commit>

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