RepoBase
このコンテンツはまだ日本語訳がありません。
Defined in: src/core/repo.ts:11
Base repository interface
Extended by
Methods
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' });}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();}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?
Returns
Promise<RepoLsRemoteResult>
Example
// List all refs from originconst result = await repo.lsRemote('origin');
// List specific branchconst result = await repo.lsRemote('origin', { refs: ['main'] });
// List only tagsconst result = await repo.lsRemote('origin', { tags: true });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?
Returns
Promise<LsTreeEntry[]>
Example
// List all files in HEADconst entries = await repo.lsTree('HEAD');
// List files recursively with names onlyconst names = await repo.lsTree('HEAD', { recursive: true, nameOnly: true });
// List files in a specific directoryconst entries = await repo.lsTree('main', { paths: ['src/'] });
// Get file sizesconst entries = await repo.lsTree('HEAD', { long: true });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?
Returns
Promise<RawResult>