Git Operations
Clone, branch, commit, push, and pull inside a sandbox.
Every sandbox exposes a Git API through sandbox.git, so you can drive repositories inside the sandbox without shelling in or scripting the git binary yourself. This is the backbone of agent workflows: clone a repo into the sandbox, let the agent edit, then commit and push the result — all from your orchestrating code. All path arguments are repository paths inside the sandbox.
Supported operations
| Operation | Python | TypeScript |
|---|---|---|
| Clone a repository | clone(url, path, branch, commit_id, username, password) | clone(url, path, branch?, commitId?, username?, password?) |
| Working-tree status | status(path) | status(path) |
| List branches | branches(path) | branches(path) |
| Create a branch | create_branch(path, name) | createBranch(path, name) |
| Delete a branch | delete_branch(path, name) | deleteBranch(path, name) |
| Check out a branch | checkout_branch(path, branch) | checkoutBranch(path, branch) |
| Stage files | add(path, files) | add(path, files) |
| Commit staged changes | commit(path, message, author, email) | commit(path, message, author, email) |
| Push | push(path, username, password) | push(path, username?, password?) |
| Pull | pull(path, username, password) | pull(path, username?, password?) |
clone can target a specific branch or pin an exact commit_id; commit returns the new commit hash.
Authenticating to private repositories
clone, push, and pull accept optional username/password parameters for HTTPS authentication. With hosting providers that use personal access tokens, pass the token as the password (for GitHub, any non-empty username works with a token):
Rather than embedding tokens in your orchestration code, you can also manage credentials as project secrets and provide them to the sandbox at create time.
Note: credentials passed to
cloneare used for that operation; pass them again onpush/pullwhen the remote requires auth.
An agent loop: clone → edit → commit → push
The complete round trip, as an orchestrator would run it:
Status and branches
status returns the current branch, ahead/behind counts against the remote, and per-file staging/worktree states — enough to decide whether there's anything to commit. branches lists the branch names in the repository.
See also
- Running Commands — for git operations the API doesn't cover, run
gitdirectly withexec. - Secrets — keep tokens out of your code.