# current-git-branch

> A tool to check if files are added in a git repository

Latest version **2.0.2** (published 2025-09-20) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2025-09-20 |
| First published | 2017-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 67.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Jan Peer Stöcklmair |
| Maintainers | jpeer |
| Keywords | is, git, added, HEAD, repo, is-git, exists |

## Links

- npm: https://www.npmjs.com/package/current-git-branch
- Repository: https://github.com/JPeer264/node-current-git-branch
- Homepage: https://github.com/JPeer264/node-current-git-branch#readme
- Issues: https://github.com/JPeer264/node-current-git-branch/issues
- npm.io page: https://npm.io/package/current-git-branch

## Dependencies (1)

- [is-git-repository](https://npm.io/package/is-git-repository.md) ^3.0.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2025-09-20
- 2.0.1 — 2025-01-15
- 2.0.0 — 2025-01-14
- 1.1.0 — 2018-10-16
- 1.0.1 — 2017-12-18
- 1.0.0 — 2017-04-08

## README

# current-git-branch

[![Build Status](https://img.shields.io/github/actions/workflow/status/JPeer264/node-current-git-branch/ci.yml?branch=main)](https://github.com/JPeer264/node-current-git-branch/actions/workflows/ci.yml?query=branch%3Amain)
[![Coverage Status](https://coveralls.io/repos/github/JPeer264/node-current-git-branch/badge.svg?branch=master)](https://coveralls.io/github/JPeer264/node-current-git-branch?branch=master)

Get synchronously the current branch name

## Installation

```sh
$ npm i current-git-branch --save
```

## Usage

Returns:

- Boolean `false`: It is not a git repository
- String: The branch name

```js
import branchName from "current-git-branch";

branchName(); // false or branch name of process.cwd()
branchName({ cwd: "any/git/repo" }); // false or branch name of the directory 'any/git/repo'
branchName({ cwd: "any/git/repo", branchOptions: ["--no-color"] }); // alternatively, you may pass git-branch command options, either as a string or an array
```

## LICENSE

MIT © [Jan Peer Stöcklmair](https://www.jpeer.at)

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