Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

find-git-root

banyudu562.1kMIT1.0.4TypeScript support: included

recursively find the closest .git/

find, git, root

readme

find-git-root

Recursively find the closest .git/ and return repo path

Installation

$ npm install find-git-root

Usage

'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