Skip to content

Git

Clone, commit, push and inspect repositories inside a sandbox.

Every method shows the same operation in each SDK; pick a language once and every tab on the site follows it.

Python TypeScript Go Ruby Java

sandbox.git. Paths are repository directories in the sandbox.

Python exposes these as methods; see below.

def add(self, repo: str, paths: list[str] | None=None) -> None

Stage paths, or everything (including deletions) when none are given.

Parameter Type Default
repo str
paths list[str] | None None
Source: sdk/python/svm/git.py:180
def add_remote(self, repo: str, name: str, url: str, *, fetch: bool=False, allowed_hosts: set[str] | None=None) -> None
Parameter Type Default
repo str
name str
url str
fetch bool False
allowed_hosts set[str] | None None
Source: sdk/python/svm/git.py:224
def branches(self, repo: str) -> GitBranches
Parameter Type Default
repo str

Returns GitBranches

Source: sdk/python/svm/git.py:156
def checkout(self, repo: str, ref: str) -> None
Parameter Type Default
repo str
ref str
Source: sdk/python/svm/git.py:173
def clone(self, url: str, path: str, *, branch: str | None=None, depth: int | None=None, allowed_hosts: set[str] | None=None) -> str

Clone an HTTPS repository into path; returns path. allowed_hosts limits where it may come from.

Parameter Type Default
url str
path str
branch str | None None
depth int | None None
allowed_hosts set[str] | None None

Returns str

Source: sdk/python/svm/git.py:125
def commit(self, repo: str, message: str, *, author_name: str | None=None, author_email: str | None=None, allow_empty: bool=False) -> str

Commit what is staged; returns the new commit id.

Parameter Type Default
repo str
message str
author_name str | None None
author_email str | None None
allow_empty bool False

Returns str

Source: sdk/python/svm/git.py:184
def configure_user(self, name: str, email: str, *, scope: str='global', repo: str | None=None) -> None
Parameter Type Default
name str
email str
scope str 'global'
repo str | None None
Source: sdk/python/svm/git.py:260

Not in the Python SDK’s Git.

def create_branch(self, repo: str, name: str, *, start: str | None=None, checkout: bool=True) -> None
Parameter Type Default
repo str
name str
start str | None None
checkout bool True
Source: sdk/python/svm/git.py:169
def delete_branch(self, repo: str, name: str, *, force: bool=False) -> None
Parameter Type Default
repo str
name str
force bool False
Source: sdk/python/svm/git.py:176
def diff(self, repo: str, *, staged: bool=False, paths: list[str] | None=None) -> str
Parameter Type Default
repo str
staged bool False
paths list[str] | None None

Returns str

Source: sdk/python/svm/git.py:152
def egress_env(self) -> dict[str, str]

The proxy settings git needs while the sandbox’s layer-7 egress is on, else {}.

With the firewall on, HTTPS leaves the sandbox only through the proxy, which signs with the sandbox’s CA: git needs HTTPS_PROXY (the sandbox’s own proxy URL, credentials included) and GIT_SSL_CAINFO (the CA, written to ~/.svm/egress-ca.pem, owner-only). They are read from get_sandbox_egress at each network operation, so rules turned on or off later are followed, and passed as the command’s environment, not on its command line. Without the firewall, or without permission to read it, git runs as it always did.

Returns dict[str, str]

Raises GitError

Source: sdk/python/svm/git.py:93
def fetch(self, repo: str, *, remote: str='origin', prune: bool=False) -> None
Parameter Type Default
repo str
remote str 'origin'
prune bool False
Source: sdk/python/svm/git.py:244
def get_config(self, key: str, *, scope: str='global', repo: str | None=None) -> str | None
Parameter Type Default
key str
scope str 'global'
repo str | None None

Returns str \| None

Raises GitError

Source: sdk/python/svm/git.py:251

Not in the Python SDK’s Git.

def install_credentials(self, git_config: str) -> None

Append the create response’s scoped proxy configuration (access.git_config) to ~/.gitconfig, owner-only.

The configuration holds only a scoped token the proxy swaps for the team’s credential; nothing else is accepted.

Parameter Type Default
git_config str

Raises GitError

Source: sdk/python/svm/git.py:273
def log(self, repo: str, *, limit: int=20, ref: str='HEAD') -> list[GitCommit]
Parameter Type Default
repo str
limit int 20
ref str 'HEAD'

Returns list[GitCommit]

Source: sdk/python/svm/git.py:146
def pull(self, repo: str, *, remote: str | None=None, branch: str | None=None, rebase: bool=False) -> None
Parameter Type Default
repo str
remote str | None None
branch str | None None
rebase bool False
Source: sdk/python/svm/git.py:237
def push(self, repo: str, *, remote: str='origin', branch: str | None=None, set_upstream: bool=False, force: bool=False) -> None

Push branch (default: the current one). force uses --force-with-lease, never a blind force.

Parameter Type Default
repo str
remote str 'origin'
branch str | None None
set_upstream bool False
force bool False
Source: sdk/python/svm/git.py:231
def remotes(self, repo: str) -> dict[str, str]

Remote name to fetch URL.

Parameter Type Default
repo str

Returns dict[str, str]

Source: sdk/python/svm/git.py:213
def remove_remote(self, repo: str, name: str) -> None
Parameter Type Default
repo str
name str
Source: sdk/python/svm/git.py:228
def reset(self, repo: str, *, ref: str='HEAD', mode: str='mixed', paths: list[str] | None=None) -> None
Parameter Type Default
repo str
ref str 'HEAD'
mode str 'mixed'
paths list[str] | None None
Source: sdk/python/svm/git.py:197
def restore(self, repo: str, paths: list[str], *, staged: bool=False, source: str | None=None) -> None

Discard working-tree changes to paths, or unstage them with staged=True.

Parameter Type Default
repo str
paths list[str]
staged bool False
source str | None None
Source: sdk/python/svm/git.py:205
def run(self, repo: str | None, *args: str, timeout_seconds: int | None=None, envs: dict[str, str] | None=None) -> ProcessResult

Any git command, quoted; the result whatever the exit code. envs are variables for this command only.

Parameter Type Default
repo str | None
args str optional
timeout_seconds int | None None
envs dict[str, str] | None None

Returns ProcessResult

Source: sdk/python/svm/git.py:88

Not in the Python SDK’s Git.

def set_config(self, key: str, value: str, *, scope: str='global', repo: str | None=None) -> None
Parameter Type Default
key str
value str
scope str 'global'
repo str | None None
Source: sdk/python/svm/git.py:248
def status(self, repo: str) -> GitStatus
Parameter Type Default
repo str

Returns GitStatus

Source: sdk/python/svm/git.py:143
Python TypeScript Go Ruby Java
Property Type Description
ahead int
behind int
branch str
clean bool
files list[GitFileStatus]
upstream str
Python TypeScript Go Ruby Java

GitFileStatus is one porcelain entry: Index and Worktree are the X and Y codes (” “, M, A, D, R, C, U, ? untracked).

Property Type Description
index str
path str
renamed_from str
worktree str
Python TypeScript Go Ruby Java

GitBranches lists local and remote-tracking branches.

Property Type Description
current str
local list[str]
remote list[str]
Python TypeScript Go Ruby Java

GitCommit is one log entry.

Property Type Description
author_email str
author_name str
id str
subject str
timestamp int
Python TypeScript Go Ruby Java

A git command exited non-zero; exit_code, stderr and stdout say why (a pull that stops on a conflict reports it on stdout).

Python exposes these as methods; see below.

Not in the Python SDK’s GitError.

Not in the Python SDK’s GitError.

Not in the Python SDK’s GitError.