Skip to content

BareRepo

Defined in: src/core/repo.ts:3575

Bare repository (no working directory)

A bare repository contains only the Git data without a working tree. Typically used for shared/server repositories.

Extends

Properties

config

config: ConfigOperations

Defined in: src/core/repo.ts:3605

Config operations (repository-level)

Wraps: git config subcommands


gitDir

readonly gitDir: string

Defined in: src/core/repo.ts:3577

Path to the git directory


remote

remote: RemoteOperations

Defined in: src/core/repo.ts:3598

Remote operations

Wraps: git remote subcommands

Methods

fetch()

fetch(opts?): Promise<void>

Defined in: src/core/repo.ts:3584

Fetch from remote

Wraps: git fetch

Parameters

opts?

FetchOpts & ExecOpts

Returns

Promise<void>


isBare()

isBare(): Promise<boolean>

Defined in: src/core/repo.ts:57

Check if this repository is a bare repository (no working directory)

Wraps: git rev-parse --is-bare-repository

This is a runtime check that queries git to determine the repository type. Note: TypeScript cannot automatically narrow the type based on this check since it returns Promise<boolean>. Use type assertions after checking.

Returns

Promise<boolean>

Example

const repo = await git.openRaw('/path/to/repo');
if (await repo.isBare()) {
// Use type assertion to access BareRepo methods
await (repo as BareRepo).fetch({ remote: 'origin' });
}

Inherited from

RepoBase.isBare


isWorktree()

isWorktree(): Promise<boolean>

Defined in: src/core/repo.ts:37

Check if this repository is a worktree repository (has working directory)

Wraps: git rev-parse --is-inside-work-tree

This is a runtime check that queries git to determine the repository type. Note: TypeScript cannot automatically narrow the type based on this check since it returns Promise<boolean>. Use type assertions after checking.

Returns

Promise<boolean>

Example

const repo = await git.openRaw('/path/to/repo');
if (await repo.isWorktree()) {
// Use type assertion to access WorktreeRepo methods
const status = await (repo as WorktreeRepo).status();
}

Inherited from

RepoBase.isWorktree


lsRemote()

lsRemote(remote, opts?): Promise<RepoLsRemoteResult>

Defined in: src/core/repo.ts:79

List references in a remote repository

Wraps: git ls-remote <remote> [refs...]

Unlike the global git.lsRemote(url), this method operates in the context of a repository and accepts a remote name (e.g., ‘origin’) instead of a URL.

Parameters

remote

string

opts?

RepoLsRemoteOpts & ExecOpts

Returns

Promise<RepoLsRemoteResult>

Example

// List all refs from origin
const result = await repo.lsRemote('origin');
// List specific branch
const result = await repo.lsRemote('origin', { refs: ['main'] });
// List only tags
const result = await repo.lsRemote('origin', { tags: true });

Inherited from

RepoBase.lsRemote


lsTree()

lsTree(treeish, opts?): Promise<LsTreeEntry[]>

Defined in: src/core/repo.ts:103

List contents of a tree object

Wraps: git ls-tree <tree-ish> [<path>...]

Lists the contents of a given tree object (commit, tag, or tree hash).

Parameters

treeish

string

opts?

LsTreeOpts & ExecOpts

Returns

Promise<LsTreeEntry[]>

Example

// List all files in HEAD
const entries = await repo.lsTree('HEAD');
// List files recursively with names only
const names = await repo.lsTree('HEAD', { recursive: true, nameOnly: true });
// List files in a specific directory
const entries = await repo.lsTree('main', { paths: ['src/'] });
// Get file sizes
const entries = await repo.lsTree('HEAD', { long: true });

Inherited from

RepoBase.lsTree


push()

push(opts?): Promise<void>

Defined in: src/core/repo.ts:3591

Push to remote

Wraps: git push

Parameters

opts?

PushOpts & ExecOpts

Returns

Promise<void>


raw()

raw(argv, opts?): Promise<RawResult>

Defined in: src/core/repo.ts:17

Execute a raw git command in this repository context

Wraps: git <argv...>

Parameters

argv

string[]

opts?

ExecOpts

Returns

Promise<RawResult>

Inherited from

RepoBase.raw


revParse()

Call Signature

revParse(ref, opts?): Promise<string>

Defined in: src/core/repo.ts:3619

Parse revision specification and return information about the repository

Wraps: git rev-parse

Parameters
ref

string

opts?

RevParseRefOpts & ExecOpts

Returns

Promise<string>

Example
const sha = await repo.revParse('HEAD');
const gitDir = await repo.revParse({ gitDir: true });
const isShallow = await repo.revParse({ isShallowRepository: true });

Call Signature

revParse(opts): Promise<string>

Defined in: src/core/repo.ts:3620

Parameters
opts

RevParsePathQuery & RevParsePathOpts & ExecOpts

Returns

Promise<string>

Call Signature

revParse(opts): Promise<boolean>

Defined in: src/core/repo.ts:3621

Parameters
opts

RevParseBooleanQuery & ExecOpts

Returns

Promise<boolean>

Call Signature

revParse(opts): Promise<string[]>

Defined in: src/core/repo.ts:3622

Parameters
opts

RevParseListQuery & ExecOpts

Returns

Promise<string[]>

Call Signature

revParse(opts): Promise<string>

Defined in: src/core/repo.ts:3623

Parameters
opts

object & ExecOpts

Returns

Promise<string>

Call Signature

revParse(opts): Promise<string>

Defined in: src/core/repo.ts:3626

Parameters
opts

object & ExecOpts

Returns

Promise<string>

Call Signature

revParse(opts): Promise<string[]>

Defined in: src/core/repo.ts:3627

Parameters
opts

object & ExecOpts

Returns

Promise<string[]>