Skip to main content

Git API

Git API - git operations

import { CodeBoltClient } from '@codebolt/clientsdk';

const client = new CodeBoltClient();

Quick Reference

MethodDescription
branchLists branches in the repository.
checkoutChecks out an existing branch or commit.
commitCreates a new Git commit with the staged changes.
createBranchCreates a new Git branch.
diffRetrieves the current diff of changes in the working directory.
downloadDownloads (clones) a remote Git repository.
getRemoteUrlRetrieves the configured remote URL for the repository.
graphRetrieves the commit graph (history) of the repository.
initInitializes a new Git repository in the workspace.
publishRemotePublishes the local repository to a new remote.
pullPulls changes from the remote repository.
pushPushes committed changes to the remote repository.
pushToRemotePushes committed changes to the remote repository.
revertReverts changes to tracked files in the working directory.
revertUntrackedRemoves untracked files from the working directory.
statusRetrieves the current Git status of the working directory.

Methods


branch

client.git.branch(data?: GitBranchRequest): Promise<GitBranch[]>

Lists branches in the repository.

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

ParameterTypeRequiredDescription
dataGitBranchRequestNoOptional parameters to filter branches (e.g., local-only, remote)

Returns: Promise<GitBranch[]> — A promise that resolves to an array of objects

Full reference →


checkout

client.git.checkout(data: GitCheckoutRequest): Promise<unknown>

Checks out an existing branch or commit.

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

ParameterTypeRequiredDescription
dataGitCheckoutRequestYesCheckout parameters specifying the target branch or commit

Returns: Promise<unknown> — A promise that resolves when the checkout is complete

Full reference →


commit

client.git.commit(data: GitCommitRequest): Promise<unknown>

Creates a new Git commit with the staged changes.

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

ParameterTypeRequiredDescription
dataGitCommitRequestYesCommit parameters including the commit message

Returns: Promise<unknown> — A promise that resolves when the commit is created

Full reference →


createBranch

client.git.createBranch(data: GitCreateBranchRequest): Promise<unknown>

Creates a new Git branch.

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

ParameterTypeRequiredDescription
dataGitCreateBranchRequestYesBranch creation parameters including the new branch name

Returns: Promise<unknown> — A promise that resolves when the branch has been created

Full reference →


diff

client.git.diff(data?: GitDiffRequest): Promise<GitDiff[]>

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.

ParameterTypeRequiredDescription
dataGitDiffRequestNoOptional filter parameters

Returns: Promise<GitDiff[]> — A promise that resolves to an array of objects with file changes and line modifications

Full reference →


download

client.git.download(data: GitDownloadRequest): Promise<unknown>

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.

ParameterTypeRequiredDescription
dataGitDownloadRequestYesClone parameters including the repository URL

Returns: Promise<unknown> — A promise that resolves when the download/clone is complete

Full reference →


getRemoteUrl

client.git.getRemoteUrl(): Promise<GitRemoteUrlResponse>

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.

No parameters.

Returns: Promise<GitRemoteUrlResponse> — A promise that resolves to a containing the remote URL

Full reference →


graph

client.git.graph(data?: GitGraphRequest): Promise<GitCommit[]>

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.

ParameterTypeRequiredDescription
dataGitGraphRequestNoOptional parameters to filter the graph (e.g., branch, limit)

Returns: Promise<GitCommit[]> — A promise that resolves to an array of objects

Full reference →


init

client.git.init(data?: GitInitRequest): Promise<unknown>

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.

ParameterTypeRequiredDescription
dataGitInitRequestNoOptional initialization parameters such as default branch name

Returns: Promise<unknown> — A promise that resolves when initialization is complete

Full reference →


publishRemote

client.git.publishRemote(data: GitPublishRemoteRequest): Promise<unknown>

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.

ParameterTypeRequiredDescription
dataGitPublishRemoteRequestYesRemote publication parameters including the target URL

Returns: Promise<unknown> — A promise that resolves when publishing is complete

Full reference →


pull

client.git.pull(data?: GitPullRequest): Promise<unknown>

Pulls changes from the remote repository.

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

ParameterTypeRequiredDescription
dataGitPullRequestNoOptional pull parameters such as remote name or branch

Returns: Promise<unknown> — A promise that resolves when the pull is complete

Full reference →


push

client.git.push(data?: GitPushRequest): Promise<unknown>

Pushes committed changes to the remote repository.

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

ParameterTypeRequiredDescription
dataGitPushRequestNoOptional push parameters such as branch or force flag

Returns: Promise<unknown> — A promise that resolves when the push is complete

Full reference →


pushToRemote

client.git.pushToRemote(data?: GitPushRequest): Promise<unknown>

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.

ParameterTypeRequiredDescription
dataGitPushRequestNoOptional push parameters such as branch or force flag

Returns: Promise<unknown> — A promise that resolves when the push is complete

Full reference →


revert

client.git.revert(data: GitRevertRequest): Promise<unknown>

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.

ParameterTypeRequiredDescription
dataGitRevertRequestYesRequest specifying which files to revert

Returns: Promise<unknown> — A promise that resolves when the revert is complete

Full reference →


revertUntracked

client.git.revertUntracked(data: GitRevertRequest): Promise<unknown>

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.

ParameterTypeRequiredDescription
dataGitRevertRequestYesRequest specifying which untracked files to remove

Returns: Promise<unknown> — A promise that resolves when the untracked files have been removed

Full reference →


status

client.git.status(data?: GitStatusRequest): Promise<GitStatus>

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.

ParameterTypeRequiredDescription
dataGitStatusRequestNoOptional parameters to scope the status check

Returns: Promise<GitStatus> — A promise that resolves to the of the repository

Full reference →