I\'d like to get the id/hash of the most recent commit on the current branch in NodeJS.
In NodeJS, I\'d like to get the most recent id/hash, with respect to git and
Short solution, no external module needed (synchronous alternative to Edin's answer):
revision = require('child_process')
.execSync('git rev-parse HEAD')
.toString().trim()
and if you want to manually specify the root directory of the git project, use the second argument of execSync
to pass the cwd
option, like execSync('git rev-parse HEAD', {cwd: __dirname})