Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (29.3k points)

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

1 Answer

0 votes
by (50.2k points)

Instead of plumbing, you could use:

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

Which will do exactly what you want. 

But if you need plumbing at any cause then you can use rev-list:

git rev-list --format=%B --max-count=1 <commit>

Note: The rev-list will also print out the commit sha in addition to the commit message.

Reference: https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---formatltformatgt

Browse Categories

...