# git-branch

> Get the current branch from the local git repository.

Latest version **2.0.1** (published 2018-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install git-branch
pnpm add git-branch
yarn add git-branch
bun add git-branch
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2018-03-09 |
| First published | 2014-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/git-branch) |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 92 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | branch, git |

## Links

- npm: https://www.npmjs.com/package/git-branch
- Repository: https://github.com/jonschlinkert/git-branch
- Issues: https://github.com/jonschlinkert/git-branch/issues
- npm.io page: https://npm.io/package/git-branch

## Dependencies (1)

- [findup-sync](https://npm.io/package/findup-sync.md) ^2.0.0

## Recent versions

- 2.0.1 (latest) — 2018-03-09
- 2.0.0 — 2018-03-09
- 1.0.0 — 2017-06-02
- 0.3.0 — 2015-03-09
- 0.2.0 — 2015-02-25
- 0.1.2 — 2014-04-04
- 0.1.1 — 2014-04-04
- 0.1.0 — 2014-04-04

## README

# git-branch [![NPM version](https://img.shields.io/npm/v/git-branch.svg?style=flat)](https://www.npmjs.com/package/git-branch) [![NPM monthly downloads](https://img.shields.io/npm/dm/git-branch.svg?style=flat)](https://npmjs.org/package/git-branch) [![NPM total downloads](https://img.shields.io/npm/dt/git-branch.svg?style=flat)](https://npmjs.org/package/git-branch) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/git-branch.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/git-branch)

> Get the current branch from the local git repository.

Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save git-branch
```

## Usage

```js
const branch = require('git-branch');
```

Optionally pass the cwd (current working directory) as the first argument.

**Promise**

```js
branch('some/path')
  .then(name => console.log('Branch:', name)) //=> 'master'
  .catch(console.error);
```

**Callback**

```js
branch(function(err, name) {
  if (err) throw err;
  console.log('Branch:', name); //=> 'master'
});
```

**Sync**

```js
console.log('Branch:', branch.sync()); //=> 'master'
```

## About

<details>
<summary><strong>Contributing</strong></summary>

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

</details>

<details>
<summary><strong>Running Tests</strong></summary>

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

</details>

<details>
<summary><strong>Building docs</strong></summary>

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

</details>

### Related projects

You might also be interested in these projects:

* [git-add-remote](https://www.npmjs.com/package/git-add-remote): API for adding git remotes. | [homepage](https://github.com/jonschlinkert/git-add-remote "API for adding git remotes.")
* [git-user-name](https://www.npmjs.com/package/git-user-name): Get a user's name from git config at the project or global scope, depending on… [more](https://github.com/jonschlinkert/git-user-name) | [homepage](https://github.com/jonschlinkert/git-user-name "Get a user's name from git config at the project or global scope, depending on what git uses in the current context.")
* [github-base](https://www.npmjs.com/package/github-base): JavaScript wrapper that greatly simplifies working with GitHub's API. | [homepage](https://github.com/jonschlinkert/github-base "JavaScript wrapper that greatly simplifies working with GitHub's API.")

### Contributors

| **Commits** | **Contributor** | 
| --- | --- |
| 19 | [jonschlinkert](https://github.com/jonschlinkert) |
| 6 | [emilrowland](https://github.com/emilrowland) |

### Author

**Jon Schlinkert**

* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)

### License

Copyright © 2018, [Jon Schlinkert](http://github.com/https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on March 09, 2018._

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