Skip to content

Instantly share code, notes, and snippets.

@kulakowka
Created January 24, 2019 12:50
Show Gist options
  • Save kulakowka/4b5c5cf45a631ee2332b467366c36ab2 to your computer and use it in GitHub Desktop.
Save kulakowka/4b5c5cf45a631ee2332b467366c36ab2 to your computer and use it in GitHub Desktop.
Getting a commit hash in node.js
const git = require("git-rev-sync");
console.log(git.short());
// 75bf4ee
console.log(git.long());
// 75bf4eea9aa1a7fd6505d0d0aa43105feafa92ef
console.log(git.branch());
// master
/**
GIT_REV=`git rev-parse --short HEAD` npm start
*/
console.log(process.env.GIT_REV)
// 75bf4ee
@meFqulted
Copy link

.slice(0, 7);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment