Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
How do I get the git commit description in node?

I need a safe consitent way to get the git description of latest commit in node.js

git commit -m "some message" -m "this is the description"

I am using require('child_process').execSync('git log -1').toString();

which outputs:

commit f8f42hash5556666b3c518e3hash294b62e88888
Author: Developer Name <email@email.com>
Date:   Tue Jun 28 08:10:09 2022 +0200

    some message

    this is the description

And I know that it is possible to add some -format='????' but following this guide; https://devhints.io/git-log-format I can't seem to find a option that gives me the description...

Edit: I see comments about description and message being treated as oine thing, which surprises me, because gitlabs interface can in fact tell the difference, I have also seen them as separetae fields in som GUI git manager (maybe git kraken or a vscode plugin)..

Here's how it looks in gitlab (--skipSmokeTest is the description) enter image description here

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can get the message like this: git log -1 --format='%b'
It will return:

some message

this is the description

Then you can extract the second line of text using JavaScript.

about 4 years ago · Juan Pablo Isaza Report

0

Beware the correct option is --pretty according to the Git log doc !

For me, you should use this, it works for me: git log -1 --pretty="format:%s".

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!