find-gitdir
Find .git
directory with support of submodules and --separate-git-dir
.
Usage
const 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 // /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 // /example/.git/modules/beep
By default find-gitdir
does not look in parent directories. It can be enabled:
await // nullawait // /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