Skip to main content

GitApi

@codebolt/client-sdk


Class: GitApi

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:30

Provides Git version control operations for the workspace.

This API wraps common Git commands -- init, commit, push, pull, branch management, and diff inspection -- allowing agents and UI components to interact with the project's Git repository programmatically.

Constructors

Constructor

new GitApi(http: HttpClient): GitApi;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:31

Parameters

ParameterType
httpHttpClient

Returns

GitApi

Methods

branch()

branch(data?: GitBranchRequest): Promise<GitBranch[]>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:289

Lists branches in the repository.

Returns all local (and optionally remote) branches with their metadata. Useful for branch selection UIs and workflow logic.

Parameters

ParameterTypeDescription
data?GitBranchRequestOptional parameters to filter branches (e.g., local-only, remote)

Returns

Promise<GitBranch[]>

A promise that resolves to an array of GitBranch objects

Example

const branches = await client.git.branch();
branches.forEach(b => console.log(b.name));

checkout()

checkout(data: GitCheckoutRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:308

Checks out an existing branch or commit.

Switches the working directory to the specified branch, tag, or commit hash.

Parameters

ParameterTypeDescription
dataGitCheckoutRequestCheckout parameters specifying the target branch or commit

Returns

Promise<unknown>

A promise that resolves when the checkout is complete

Example

await client.git.checkout({ branch: 'feature/auth' });

commit()

commit(data: GitCommitRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:160

Creates a new Git commit with the staged changes.

Commits all currently staged files with the provided commit message and optional author information.

Parameters

ParameterTypeDescription
dataGitCommitRequestCommit parameters including the commit message

Returns

Promise<unknown>

A promise that resolves when the commit is created

Example

await client.git.commit({ message: 'feat: add user authentication' });

createBranch()

createBranch(data: GitCreateBranchRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:327

Creates a new Git branch.

Creates a branch with the specified name, optionally based on a given starting point (commit, tag, or another branch).

Parameters

ParameterTypeDescription
dataGitCreateBranchRequestBranch creation parameters including the new branch name

Returns

Promise<unknown>

A promise that resolves when the branch has been created

Example

await client.git.createBranch({ name: 'feature/new-feature' });

diff()

diff(data?: GitDiffRequest): Promise<GitDiff[]>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:104

Retrieves the current diff of changes in the working directory.

Compares the working tree against the latest commit to show all unstaged modifications. Optionally filters to a specific file path.

Parameters

ParameterTypeDescription
data?GitDiffRequestOptional filter parameters

Returns

Promise<GitDiff[]>

A promise that resolves to an array of GitDiff objects with file changes and line modifications

Example

const diffs = await client.git.diff({ file: 'src/index.ts' });

download()

download(data: GitDownloadRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:198

Downloads (clones) a remote Git repository.

Clones a repository from a URL into the workspace. Use this to set up a project from an existing remote repository.

Parameters

ParameterTypeDescription
dataGitDownloadRequestClone parameters including the repository URL

Returns

Promise<unknown>

A promise that resolves when the download/clone is complete

Example

await client.git.download({ url: 'https://github.com/org/repo.git' });

getRemoteUrl()

getRemoteUrl(): Promise<GitRemoteUrlResponse>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:47

Retrieves the configured remote URL for the repository.

Returns the URL of the primary remote (typically "origin"). Useful for displaying repository information or constructing web links.

Returns

Promise<GitRemoteUrlResponse>

A promise that resolves to a GitRemoteUrlResponse containing the remote URL

Example

const remote = await client.git.getRemoteUrl();
console.log(remote.url); // e.g., 'https://github.com/org/repo.git'

graph()

graph(data?: GitGraphRequest): Promise<GitCommit[]>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:84

Retrieves the commit graph (history) of the repository.

Returns an array of commits representing the repository's history. Useful for rendering commit timelines or inspecting past changes.

Parameters

ParameterTypeDescription
data?GitGraphRequestOptional parameters to filter the graph (e.g., branch, limit)

Returns

Promise<GitCommit[]>

A promise that resolves to an array of GitCommit objects

Example

const commits = await client.git.graph({ limit: 20 });
commits.forEach(c => console.log(c.message));

init()

init(data?: GitInitRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:65

Initializes a new Git repository in the workspace.

Creates a new .git directory and sets up the repository. If the repository already exists, behavior depends on the server configuration.

Parameters

ParameterTypeDescription
data?GitInitRequestOptional initialization parameters such as default branch name

Returns

Promise<unknown>

A promise that resolves when initialization is complete

Example

await client.git.init();

publishRemote()

publishRemote(data: GitPublishRemoteRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:216

Publishes the local repository to a new remote.

Sets up a remote and pushes the local repository to it for the first time. Use this when the repository does not yet have a remote configured.

Parameters

ParameterTypeDescription
dataGitPublishRemoteRequestRemote publication parameters including the target URL

Returns

Promise<unknown>

A promise that resolves when publishing is complete

Example

await client.git.publishRemote({ url: 'https://github.com/org/new-repo.git' });

pull()

pull(data?: GitPullRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:252

Pulls changes from the remote repository.

Downloads and integrates remote changes into the current branch. Equivalent to running git pull from the command line.

Parameters

ParameterTypeDescription
data?GitPullRequestOptional pull parameters such as remote name or branch

Returns

Promise<unknown>

A promise that resolves when the pull is complete

Example

await client.git.pull();

push()

push(data?: GitPushRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:270

Pushes committed changes to the remote repository.

An alias for pushToRemote providing a shorter method name. Both methods perform the same push operation.

Parameters

ParameterTypeDescription
data?GitPushRequestOptional push parameters such as branch or force flag

Returns

Promise<unknown>

A promise that resolves when the push is complete

Example

await client.git.push();

pushToRemote()

pushToRemote(data?: GitPushRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:234

Pushes committed changes to the remote repository.

Uploads local commits to the configured remote. This is the standard way to share local changes with the remote repository.

Parameters

ParameterTypeDescription
data?GitPushRequestOptional push parameters such as branch or force flag

Returns

Promise<unknown>

A promise that resolves when the push is complete

Example

await client.git.pushToRemote();

revert()

revert(data: GitRevertRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:122

Reverts changes to tracked files in the working directory.

Discards uncommitted modifications to files that are already tracked by Git, restoring them to their last committed state.

Parameters

ParameterTypeDescription
dataGitRevertRequestRequest specifying which files to revert

Returns

Promise<unknown>

A promise that resolves when the revert is complete

Example

await client.git.revert({ files: ['src/index.ts'] });

revertUntracked()

revertUntracked(data: GitRevertRequest): Promise<unknown>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:141

Removes untracked files from the working directory.

Deletes files that are not tracked by Git (i.e., new files that have not been staged or committed). Use with caution as this operation cannot be undone.

Parameters

ParameterTypeDescription
dataGitRevertRequestRequest specifying which untracked files to remove

Returns

Promise<unknown>

A promise that resolves when the untracked files have been removed

Example

await client.git.revertUntracked({ files: ['temp.log'] });

status()

status(data?: GitStatusRequest): Promise<GitStatus>;

Defined in: CodeBolt/packages/clientsdk/src/api/git.api.ts:179

Retrieves the current Git status of the working directory.

Returns information about staged, unstaged, and untracked files, similar to running git status from the command line.

Parameters

ParameterTypeDescription
data?GitStatusRequestOptional parameters to scope the status check

Returns

Promise<GitStatus>

A promise that resolves to the GitStatus of the repository

Example

const status = await client.git.status();
console.log(status); // modified files, staged changes, etc.