# find-git-root

> recursively find the closest .git/

Latest version **1.1.0** (published 2026-01-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install find-git-root
pnpm add find-git-root
yarn add find-git-root
bun add find-git-root
```

## Health

**Score 55/100 (C)** — status: stable.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-01-27 |
| First published | 2017-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Yudu Ban |
| Maintainers | banyudu |
| Keywords | find, git, root |

## Links

- npm: https://www.npmjs.com/package/find-git-root
- Repository: https://github.com/banyudu/find-git-root
- Homepage: https://github.com/banyudu/find-git-root#readme
- Issues: https://github.com/banyudu/find-git-root/issues
- npm.io page: https://npm.io/package/find-git-root

## Recent versions

- 1.1.0 (latest) — 2026-01-27
- 1.0.4 — 2020-02-21
- 1.0.3 — 2020-02-21
- 1.0.2 — 2019-07-08
- 1.0.1 — 2019-07-03
- 1.0.0 — 2019-05-13
- 0.1.2 — 2019-05-13
- 0.1.0 — 2017-04-28

## README

# find-git-root

[![Shields Badge](https://img.shields.io/npm/dw/find-git-root.svg)](https://npmjs.com/package/find-git-root)

Recursively find the closest `.git/` and return repo path, support git worktree.

## Installation

```bash
npm install find-git-root
```

## Usage

```javascript
'use strict'

const findGitRoot = require('find-git-root')

// git clone url /home/you/repo
const root = findGitRoot('/home/you/repo/somedir/somefile')
// => /home/you/repo/.git

const root = findGitRoot('/home/you/repo/somedir')
// => /home/you/repo/.git
```

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