openRepository
Attempt to open an already-existing repository at path
.
Signature
function openRepository(
path: string,
options?: RepositoryOpenOptions,
signal?: AbortSignal,
): Promise<Repository>;
Parameters
- pathrequired · string
Directory path to repository already-existing.
- optionsnull | RepositoryOpenOptions
Options which can be used to configure how a repository is initialized.
- bareboolean
If this option is
true
, force opening the repository as bare event if it isn't, ignoring any working directory, and defer loading the repository configuration for performance. - ceilingDirsstring[]
ceiling_dirs specifies a list of paths that the search through parent directories will stop before entering.
- crossFsboolean
If this option is
true
, the search through parent directories will not cross a filesystem boundary (detected when the stat st_dev field changes). - fromEnvboolean
If this option is
true
,open
will ignore other options andceilingDirs
, and respect the same environment variables git does. Note, however, thatpath
overrides$GIT_DIR
. - noDotgitboolean
If this options is
true
, don't try appending/.git
topath
. - noSearchboolean
If this option is
true
, the path must point directly to a repository; otherwise, this may point to a subdirectory of a repository, andopen
will search up through parent directories.
- bareboolean
- signalnull | AbortSignal
Abort signal.
Returns
- Promise<Repository>
Opened repository.
Examples
Basic example.
import { openRepository } from 'es-git';
const repo = await openRepository('/path/to/repo');
Open bare repository.
import { openRepository } from 'es-git';
const repo = await openRepository('/path/to/repo.git', {
bare: true,
});