Skip to content
View as Markdown

Git operations facade for a specific Sandbox.

Provides repository clone, branch, commit, status, and sync operations mapped to Daytona toolbox Git endpoints.

public void clone(String url, String path)

Clones a Git repository into the specified path.

Parameters:

  • url String - repository URL
  • path String - destination path in the Sandbox

Throws:

  • io.daytona.sdk.exception.DaytonaException - if cloning fails
public void clone(String url, String path, String branch, String commitId, String username, String password)

Clones a repository with optional branch, commit, and credentials.

Parameters:

  • url String - repository URL
  • path String - destination path in the Sandbox
  • branch String - branch to clone; null uses default branch
  • commitId String - commit SHA to checkout after clone; null skips detached checkout
  • username String - username for authenticated remotes
  • password String - password or token for authenticated remotes

Throws:

  • io.daytona.sdk.exception.DaytonaException - if cloning fails
public void clone(String url, String path, String branch, String commitId, String username, String password, Boolean insecureSkipTls)

Clones a repository with optional branch, commit, credentials, and TLS verification override.

Parameters:

  • url String - repository URL
  • path String - destination path in the Sandbox
  • branch String - branch to clone; null uses default branch
  • commitId String - commit SHA to checkout after clone; null skips detached checkout
  • username String - username for authenticated remotes
  • password String - password or token for authenticated remotes
  • insecureSkipTls Boolean - when true, skip TLS certificate verification (insecure). Use only for trusted internal Git servers with self-signed or private-CA certs; credentials, if supplied, are transmitted over an unverified TLS connection. null or false keeps strict TLS verification.

Throws:

  • io.daytona.sdk.exception.DaytonaException - if cloning fails
public void clone(String url, String path, String branch, String commitId, String username, String password, Boolean insecureSkipTls, Integer depth)

Clones a repository with optional branch, commit, credentials, TLS verification override, and shallow depth.

Parameters:

  • url String - repository URL
  • path String - destination path in the Sandbox
  • branch String - branch to clone; null uses default branch
  • commitId String - commit SHA to checkout after clone; null skips detached checkout
  • username String - username for authenticated remotes
  • password String - password or token for authenticated remotes
  • insecureSkipTls Boolean - when true, skip TLS certificate verification (insecure)
  • depth Integer - create a shallow clone truncated to the given number of commits; null clones full history

Throws:

  • io.daytona.sdk.exception.DaytonaException - if cloning fails
public Map<String, Object> branches(String path)

Lists branches in a repository.

Parameters:

  • path String - repository path in the Sandbox

Returns:

  • Map\<String, Object\> - map containing branches list

Throws:

  • io.daytona.sdk.exception.DaytonaException - if the operation fails
public void add(String path, List<String> files)

Stages files for commit.

Parameters:

  • path String - repository path in the Sandbox
  • files List<String> - file paths to stage relative to repository root

Throws:

  • io.daytona.sdk.exception.DaytonaException - if staging fails
public GitCommitResponse commit(String path, String message, String author, String email)

Creates a commit from staged changes.

Parameters:

  • path String - repository path in the Sandbox
  • message String - commit message
  • author String - author display name
  • email String - author email address

Returns:

  • GitCommitResponse - commit metadata containing resulting hash

Throws:

  • io.daytona.sdk.exception.DaytonaException - if commit fails
public GitStatus status(String path)

Retrieves Git status for a repository.

Parameters:

  • path String - repository path in the Sandbox

Returns:

  • GitStatus - repository status including branch divergence and file status entries

Throws:

  • io.daytona.sdk.exception.DaytonaException - if the operation fails
public void push(String path)

Pushes local commits to remote.

Parameters:

  • path String - repository path in the Sandbox

Throws:

  • io.daytona.sdk.exception.DaytonaException - if push fails
public void push(String path, String username, String password, String branch, String remote, Boolean setUpstream)

Pushes local commits to remote with optional credentials, branch, remote, and upstream tracking.

Parameters:

  • path String - repository path in the Sandbox
  • username String - username for authenticated remotes
  • password String - password or token for authenticated remotes
  • branch String - branch to push; null uses the current branch
  • remote String - remote to push to; null uses “origin”
  • setUpstream Boolean - when true, record the pushed branch as the upstream tracking branch

Throws:

  • io.daytona.sdk.exception.DaytonaException - if push fails
public void pull(String path)

Pulls updates from remote.

Parameters:

  • path String - repository path in the Sandbox

Throws:

  • io.daytona.sdk.exception.DaytonaException - if pull fails
public void pull(String path, String username, String password, String branch, String remote)

Pulls updates from remote with optional credentials, branch, and remote.

Parameters:

  • path String - repository path in the Sandbox
  • username String - username for authenticated remotes
  • password String - password or token for authenticated remotes
  • branch String - branch to pull; null uses the current branch’s upstream
  • remote String - remote to pull from; null uses “origin”

Throws:

  • io.daytona.sdk.exception.DaytonaException - if pull fails
public void createBranch(String path, String name)

Creates a new branch at the current HEAD.

Parameters:

  • path String - repository path in the Sandbox
  • name String - name of the new branch

Throws:

  • io.daytona.sdk.exception.DaytonaException - if branch creation fails
public void checkoutBranch(String path, String branch)

Checks out a branch or commit.

Parameters:

  • path String - repository path in the Sandbox
  • branch String - branch name or commit SHA to checkout

Throws:

  • io.daytona.sdk.exception.DaytonaException - if checkout fails
public void deleteBranch(String path, String name)

Deletes a branch.

Parameters:

  • path String - repository path in the Sandbox
  • name String - name of the branch to delete

Throws:

  • io.daytona.sdk.exception.DaytonaException - if deletion fails
public void init(String path)

Initializes a new Git repository at the specified path.

Parameters:

  • path String - destination path in the Sandbox

Throws:

  • io.daytona.sdk.exception.DaytonaException - if initialization fails
public void init(String path, Boolean bare, String initialBranch)

Initializes a new Git repository with optional bare mode and initial branch.

Parameters:

  • path String - destination path in the Sandbox
  • bare Boolean - when true, create a bare repository without a working tree
  • initialBranch String - name of the initial branch; null uses the Git default

Throws:

  • io.daytona.sdk.exception.DaytonaException - if initialization fails
public void reset(String path)

Resets the current HEAD to HEAD (mixed reset, unstaging changes).

Parameters:

  • path String - repository path in the Sandbox

Throws:

  • io.daytona.sdk.exception.DaytonaException - if reset fails
public void reset(String path, String mode, String target, List<String> files)

Resets the current HEAD to the specified state.

Parameters:

  • path String - repository path in the Sandbox
  • mode String - reset mode: “soft”, “mixed” (default), “hard”, “merge” or “keep”; null uses “mixed”
  • target String - revision to reset to; null uses HEAD
  • files List<String> - constrain the reset to the given paths; null resets all

Throws:

  • io.daytona.sdk.exception.DaytonaException - if reset fails
public void restore(String path, List<String> files)

Restores working tree files for the given paths (discarding local changes).

Parameters:

  • path String - repository path in the Sandbox
  • files List<String> - file paths to restore

Throws:

  • io.daytona.sdk.exception.DaytonaException - if restore fails
public void restore(String path, List<String> files, Boolean staged, Boolean worktree, String source)

Restores working tree files or unstages changes.

Parameters:

  • path String - repository path in the Sandbox
  • files List<String> - file paths to restore
  • staged Boolean - restore the staging index for the given files
  • worktree Boolean - restore the working tree for the given files; defaults to true when both are null
  • source String - restore file contents from the given revision instead of the index

Throws:

  • io.daytona.sdk.exception.DaytonaException - if restore fails
public void remoteAdd(String path, String name, String url)

Adds a remote to the repository.

Parameters:

  • path String - repository path in the Sandbox
  • name String - name of the remote
  • url String - URL of the remote

Throws:

  • io.daytona.sdk.exception.DaytonaException - if adding the remote fails
public void remoteAdd(String path, String name, String url, Boolean fetch, Boolean overwrite)

Adds (or overwrites) a remote in the repository.

Parameters:

  • path String - repository path in the Sandbox
  • name String - name of the remote
  • url String - URL of the remote
  • fetch Boolean - when true, fetch from the remote immediately after adding it
  • overwrite Boolean - when true, replace an existing remote with the same name

Throws:

  • io.daytona.sdk.exception.DaytonaException - if adding the remote fails
public List<GitRemote> remotes(String path)

Lists the remotes configured in the repository.

Parameters:

  • path String - repository path in the Sandbox

Returns:

  • List\<GitRemote\> - the configured remotes (name + URL)

Throws:

  • io.daytona.sdk.exception.DaytonaException - if listing remotes fails
public String remoteGet(String path, String name)

Gets the URL of a remote, or null when it does not exist.

Parameters:

  • path String - repository path in the Sandbox
  • name String - name of the remote

Returns:

  • String - the remote URL, or null when the remote does not exist

Throws:

  • io.daytona.sdk.exception.DaytonaException - if the operation fails
public void setConfig(String key, String value)

Sets a Git config value at the global scope.

Parameters:

  • key String - config key in dotted form (e.g. “user.name”)
  • value String - config value

Throws:

  • io.daytona.sdk.exception.DaytonaException - if setting config fails
public void setConfig(String key, String value, String scope, String path)

Sets a Git config value at the given scope.

Parameters:

  • key String - config key in dotted form (e.g. “user.name”)
  • value String - config value
  • scope String - config scope: “global” (default), “local” or “system”
  • path String - repository path, required when scope is “local”

Throws:

  • io.daytona.sdk.exception.DaytonaException - if setting config fails
public String getConfig(String key)

Gets a Git config value at the global scope, or null when unset.

Parameters:

  • key String - config key in dotted form (e.g. “user.name”)

Returns:

  • String - the config value, or null when the key is not set

Throws:

  • io.daytona.sdk.exception.DaytonaException - if getting config fails
public String getConfig(String key, String scope, String path)

Gets a Git config value at the given scope, or null when unset.

Parameters:

  • key String - config key in dotted form (e.g. “user.name”)
  • scope String - config scope: “global” (default), “local” or “system”
  • path String - repository path, required when scope is “local”

Returns:

  • String - the config value, or null when the key is not set

Throws:

  • io.daytona.sdk.exception.DaytonaException - if getting config fails
public void configureUser(String name, String email)

Configures the Git user name and email at the global scope.

Parameters:

  • name String - user name (user.name)
  • email String - user email (user.email)

Throws:

  • io.daytona.sdk.exception.DaytonaException - if configuring user fails
public void configureUser(String name, String email, String scope, String path)

Configures the Git user name and email at the given scope.

Parameters:

  • name String - user name (user.name)
  • email String - user email (user.email)
  • scope String - config scope: “global” (default), “local” or “system”
  • path String - repository path, required when scope is “local”

Throws:

  • io.daytona.sdk.exception.DaytonaException - if configuring user fails
public void dangerouslyAuthenticate(String username, String password)

Persists Git credentials globally so that subsequent operations against github.com authenticate automatically.

This stores the password in plaintext on disk via the Git credential store.

Parameters:

  • username String - Git username
  • password String - Git password or token

Throws:

  • io.daytona.sdk.exception.DaytonaException - if authentication fails
public void dangerouslyAuthenticate(String username, String password, String host, String protocol)

Persists Git credentials globally so that subsequent operations against the given host authenticate automatically.

This stores the password in plaintext on disk via the Git credential store.

Parameters:

  • username String - Git username
  • password String - Git password or token
  • host String - host to authenticate against; null uses “github.com”
  • protocol String - protocol to authenticate against; null uses “https”

Throws:

  • io.daytona.sdk.exception.DaytonaException - if authentication fails