I need a plumbing command to print the commit message of one given commit - nothing more, nothing less.
That's neither plumbing nor one command.
Mark Probst
2010-07-28 20:43:43
+1
A:
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.
mipadi
2010-07-28 20:47:09
No, it won't. First of all, %B is not a correct format specifier - the one you mean is %b. Second, it doesn't show the whole commit message, only what it considers the "body". Third, even if you force it to print the "subject" as well, it doesn't do so properly with commit messages that don't conform to the subject/body convention (it eats newlines), like this one: http://github.com/mono/mono/commit/e43c207e128f8f86c6ddc7989f3a1b611a193845
Mark Probst
2010-07-28 20:56:15
Worked perfectly for me - but I used `%s%b` instead of `%B` (on a Linux box)
adamk
2010-07-28 20:56:53
`%B` is a correct specifier (at least, in Git 1.7.2, not sure when it was added).
mipadi
2010-07-28 20:57:34
A:
Not plumbing, but I have these in my .gitconfig:
lsum = log -n 1 --pretty=format:'%s'
lmsg = log -n 1 --pretty=format:'%s%n%n%b'
That's "last summary" and "last message". You can provide a commit to get the summary or message of that commit. (I'm using 1.7.0.5 so don't have %B.)
bstpierre
2010-07-28 22:14:07