Git API
Git API - git operations
import { CodeBoltClient } from '@codebolt/clientsdk';
const client = new CodeBoltClient();
Quick Reference
| Method | Description |
|---|---|
branch | Lists branches in the repository. |
checkout | Checks out an existing branch or commit. |
commit | Creates a new Git commit with the staged changes. |
createBranch | Creates a new Git branch. |
diff | Retrieves the current diff of changes in the working directory. |
download | Downloads (clones) a remote Git repository. |
getRemoteUrl | Retrieves the configured remote URL for the repository. |
graph | Retrieves the commit graph (history) of the repository. |
init | Initializes a new Git repository in the workspace. |
publishRemote | Publishes the local repository to a new remote. |
pull | Pulls changes from the remote repository. |
push | Pushes committed changes to the remote repository. |
pushToRemote | Pushes committed changes to the remote repository. |
revert | Reverts changes to tracked files in the working directory. |
revertUntracked | Removes untracked files from the working directory. |
status | Retrieves 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
data | GitBranchRequest | No | Optional parameters to filter branches (e.g., local-only, remote) |
Returns: Promise<GitBranch[]> — A promise that resolves to an array of objects
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.
| Parameter | Type | Required | Description |
|---|---|---|---|
data | GitCheckoutRequest | Yes | Checkout parameters specifying the target branch or commit |
Returns: Promise<unknown> — A promise that resolves when the checkout is complete
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.
| Parameter | Type | Required | Description |
|---|---|---|---|
data | GitCommitRequest | Yes | Commit parameters including the commit message |
Returns: Promise<unknown> — A promise that resolves when the commit is created
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).
| Parameter | Type | Required | Description |
|---|---|---|---|
data | GitCreateBranchRequest | Yes | Branch creation parameters including the new branch name |
Returns: Promise<unknown> — A promise that resolves when the branch has been created
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.
| Parameter | Type | Required | Description |
|---|---|---|---|
data | GitDiffRequest | No | Optional filter parameters |
Returns: Promise<GitDiff[]> — A promise that resolves to an array of objects with file changes and line modifications