Skip to main content

Clone

from nullspace import GitHttpsAuth, Sandbox

with Sandbox.create(template="base") as sandbox:
    sandbox.git.clone(
        "https://github.com/pypa/sampleproject.git",
        path="/workspace/sampleproject",
        depth=1,
    )

Authenticated clone

auth = GitHttpsAuth(username="x-access-token", password="ghp_...")

sandbox.git.clone(
    "https://github.com/your-org/private-repo.git",
    path="/workspace/repo",
    auth=auth,
)
sandbox.git.pull(path="/workspace/repo", auth=auth)
Pass credentials from your orchestrator through environment variables or secret storage. Avoid committing tokens into the sandbox filesystem.

Branch, edit, and diff

sandbox.git.create_branch("/workspace/repo", "agent/change")
sandbox.files.write("/workspace/repo/README.md", "updated\n")
sandbox.git.add(path="/workspace/repo", files=["README.md"])
print(sandbox.git.diff(path="/workspace/repo"))

Commit and push

sandbox.git.configure_user("Agent", "agent@example.com", path="/workspace/repo")
sandbox.git.commit("Apply agent change", path="/workspace/repo")
sandbox.git.push(path="/workspace/repo", auth=auth)

SSH keys and remotes

sandbox.git.add_ssh_key(private_key)
sandbox.git.remote_add(
    path="/workspace/repo",
    name="origin-ssh",
    url="git@github.com:your-org/private-repo.git",
)

Other helpers

sandbox.git also supports pull, checkout, delete_branch, branches, remote_add, set_config, get_config, status, dangerously_authenticate, and add_ssh_key.