# local-git-sync

> Synchronously get the current git commit hash, tag, log, latest commit or branch

Latest version **2.0.0** (published 2017-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install local-git-sync
pnpm add local-git-sync
yarn add local-git-sync
bun add local-git-sync
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-04-29 |
| First published | 2016-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | kurttheviking |
| Maintainers | syberpunk |

## Links

- npm: https://www.npmjs.com/package/local-git-sync
- Repository: https://github.com/syberpunk/local-git-sync
- Issues: https://github.com/kurttheviking/git-rev-sync/issues
- npm.io page: https://npm.io/package/local-git-sync

## Dependencies (2)

- [shelljs](https://npm.io/package/shelljs.md) 0.7.4
- [graceful-fs](https://npm.io/package/graceful-fs.md) 4.1.6

## Recent versions

- 2.0.0 (latest) — 2017-04-29
- 1.8.3 — 2016-12-20
- 1.8.2 — 2016-12-20
- 1.8.1 — 2016-12-20
- 1.8.0 — 2016-12-20

## README

local-git-sync
============

[![Build Status](https://travis-ci.org/kurttheviking/git-rev-sync.svg?branch=master)](https://travis-ci.org/kurttheviking/git-rev-sync.svg?branch=master)

Synchronously get the current git commit hash, tag, count, branch, log or commit message. Forked from [git-rev-sync](https://github.com/kurttheviking/git-rev-sync).


## Example

```js
var git = require('local-git-sync');

console.log(git.short());
// 75bf4ee

console.log(git.long());
// 75bf4eea9aa1a7fd6505d0d0aa43105feafa92ef

console.log(git.branch());
// master

console.log(git.log());
// commit 393b24d4ae3d944eb6af2008246e4e22c37e0f2d
// Author: syberpunk <syberpunk@email.com>
// Date:   Mon Dec 19 17:02:46 2016 +0200
//
//  //GIT LOG TEST

console.log(git.latestCommit());
// e.g. 
// {
//   id: 393b24d4ae3d944eb6af2008246e4e22c37e0f2d,
//   revision: 1359,
//   date: Mon Dec 19 17:02:46 2016 +0200,
//   author: syberpunk,
//   message: //GIT LOG TEST
// }

```

You can also run these examples via: `npm run examples`


## Install

`npm install local-git-sync --save`


## API

``` js
var git = require('local-git-sync');
```

#### `git.short([filePath])` &rarr; &lt;String&gt;

return the result of `git rev-parse --short HEAD`; optional `filePath` parameter can be used to run the command against a repo outside the current working directory

#### `git.long([filePath])` &rarr; &lt;String&gt;

return the result of `git rev-parse HEAD`; optional `filePath` parameter can be used to run the command against a repo outside the current working directory

#### `git.branch([filePath])` &rarr; &lt;String&gt;

return the current branch; optional `filePath` parameter can be used to run the command against a repo outside the current working directory

#### `git.tag([markDirty])` &rarr; &lt;String&gt;

return the current tag and mark as dirty if markDirty is truthful; this method will fail if the `git` command is not found in your `PATH`

#### `git.isTagDirty()` &rarr; &lt;Boolean&gt;

returns true if the current tag is dirty; this method will fail if the `git` command is not found in your `PATH`

#### `git.message()` &rarr; &lt;String&gt;

return the current commit message; this method will fail if the `git` command is not found in your `PATH`

#### `git.count()` &rarr; &lt;Number&gt;

return the count of commits across all branches; this method will fail if the `git` command is not found in your `PATH`

#### `git.log()` &rarr; &lt;String&gt;

return a list of all commits; this method will fail if the `git` command is not found in your `PATH`

#### `git.latestCommit()` &rarr; &lt;Object&gt;

return the last commit as a javascript object; this method will fail if the `git` command is not found in your `PATH`

## License

[MIT](https://github.com/kurttheviking/git-rev-sync/blob/master/LICENSE)

---
_Source: https://npm.io/package/local-git-sync · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
