Git Integration
Updated at:
Agent Sandbox Flash Edition can run Git commands inside the sandbox, and can also use the Git module exposed by the E2B SDK for common repository operations. This is suitable when an agent needs to pull code, create temporary branches, run tests, and generate patches.
Run Git with Commands
const result = await sandbox.commands.run(
"git clone --depth=1 https://github.com/e2b-dev/e2b.git /tmp/repo && git -C /tmp/repo status --short",
{ timeoutMs: 120_000 },
);
console.log(result.stdout);
Python example:
result = sandbox.commands.run(
"git clone --depth=1 https://github.com/e2b-dev/e2b.git /tmp/repo && git -C /tmp/repo status --short",
timeout=120,
)
print(result.stdout)
Use the SDK Git Module
await sandbox.git.clone("https://github.com/e2b-dev/e2b.git", { path: "/tmp/repo" });
const status = await sandbox.git.status("/tmp/repo");
console.log(status);
Python example:
sandbox.git.clone("https://github.com/e2b-dev/e2b.git", path="/tmp/repo")
status = sandbox.git.status("/tmp/repo")
print(status)
Recommendations
-
When accessing private repositories, inject credentials from your application and enforce least privilege.
-
For large repositories, prefer shallow clones or fetch only the required directories.
-
Before running code from an untrusted repository, validate the security of its dependency sources, scripts, and execution commands.
Is this page helpful?