Returns commit id (commit sha) of git repository
This package is fast, has no dependencies, has synchronous API, doesn't require git binary.
Useful e.g. for CI, release for Sentry or build id for Next.js
yarn add --dev git-commit-id
If you're using npm you can use:
npm install --save-dev git-commit-id
.
const gitCommitId = require('git-commit-id')
const commitId = gitCommitId()
You can pass cwd
option to specify custom git directory:
const commitId = gitCommitId({ cwd: __dirname })
MIT