Skip to content

Find .git directory with support of submodules and --separate-git-dir.

License

Notifications You must be signed in to change notification settings

vweevers/find-gitdir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

find-gitdir

Find .git directory with support of submodules and --separate-git-dir.

npm status node Test JavaScript Style Guide

Usage

const gitdir = require('find-gitdir')

Let's say we have a git repository at /example and that this is our working directory. Its gitdir will commonly be at /example/.git.

await gitdir() // /example/.git

Let's also say we have a git submodule at ./beep. Then find-gitdir will find a symbolic link at ./beep/.git pointing to the gitdir ../.git/modules/beep:

await gitdir('./beep') // /example/.git/modules/beep

By default find-gitdir does not look in parent directories. It can be enabled:

await gitdir('./node_modules/find-gitdir')       // null
await gitdir('./node_modules/find-gitdir', true) // /example/.git

API

gitdir([cwd][, roam][, callback])

Yields an absolute path to a .git directory or null if not found, given working directory cwd which defaults to process.cwd(). Set roam to true to enable looking in parent directories. If no callback if provided, a promise is returned.

gitdir.sync([cwd][, roam])

Synchronous variant. Returns an absolute path or null.

Install

With npm do:

npm install find-gitdir

License

MIT © Vincent Weevers

About

Find .git directory with support of submodules and --separate-git-dir.

Topics

Resources

License

Stars

Watchers

Forks