Synchronously get the current git commit hash, tag, branch or commit message. Forked from git-rev.
var git = require('git-rev-sync');
console.log(git.short());
// 75bf4ee
console.log(git.long());
// 75bf4eea9aa1a7fd6505d0d0aa43105feafa92ef
console.log(git.branch());
// master
console.log(git.message());
// initial commit
console.log(git.tag());
// not implemented
console.log(git.log());
// not implemented
You can also run these examples via: npm run examples
npm install git-rev-sync --save
var git = require('git-rev-sync');
return the result of git rev-parse --short HEAD
return the result of git rev-parse HEAD
return the current branch
return the current commit message; this method will fail if the git
command is not found in your PATH