Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print commit message of a given commit in git

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

like image 821
Mark Probst Avatar asked Jul 28 '10 20:07

Mark Probst


People also ask

How do I see a commit message in git?

If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .

How do you get details of a commit?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

Which git command will show a list of previous commits with messages?

The most basic and powerful tool to do this is the git log command. By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first.


1 Answers

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.

like image 55
mipadi Avatar answered Sep 19 '22 19:09

mipadi