POST /v1/agents/runtime/{runtime_id}/git/branches
import uuid
from gravixlayer import GravixLayer
client = GravixLayer() # defaults to cloud="aws", region="us-east-1"
policy = client.network_policies.create(
name=f"git-github-{uuid.uuid4().hex[:8]}",
egress_mode="allowlist",
rules=[{"destination": "github.com", "port": 443, "protocol": "tcp"}],
)
sandbox = client.runtime.create(network_policy_ids=[policy.id]) # defaults to template="base-small"
sandbox.git.clone(
url="https://github.com/octocat/Hello-World.git",
path="/workspace/repo",
)
# Local branches (default)
r = sandbox.git.branch_list("/workspace/repo")
print(r.stdout)
# All branches: local + remote-tracking
r = sandbox.git.branch_list("/workspace/repo", scope="all")
print(r.stdout)
sandbox.kill()
client.network_policies.delete(policy.id)
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer(); // defaults to cloud="aws", region="us-east-1"
const policy = await client.networkPolicies.create(`git-github-${Date.now()}`, {
egressMode: 'allowlist',
rules: [{ destination: 'github.com', port: 443, protocol: 'tcp' }],
});
const sandbox = await client.runtime.create({ networkPolicyIds: [policy.id] }); // defaults to template="base-small"
await sandbox.git.clone('https://github.com/octocat/Hello-World.git', '/workspace/repo');
// Local branches (default)
const r = await sandbox.git.branchList("/workspace/repo");
console.log(r.stdout);
// All branches: local + remote-tracking
let listed = await sandbox.git.branchList('/workspace/repo', 'all');
console.log(listed.stdout);
await sandbox.kill();
await client.networkPolicies.delete(policy.id);
# Local branches (default)
gravixlayer runtime git branch "$RT" --path /workspace/repo
# Remote-tracking branches only
gravixlayer runtime git branch "$RT" --path /workspace/repo --remote
# Local + remote-tracking
gravixlayer runtime git branch "$RT" --path /workspace/repo --all
curl -X POST "https://api.gravixlayer.ai/v1/agents/runtime/$RT/git/branches" \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"repository_path": "/workspace/repo", "scope": "all"}'
scope maps directly onto git branch: local runs git branch, remote runs
git branch -r, and all runs git branch -a. The checked-out branch is
prefixed with * in stdout.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
repository_path | string | Yes | Path to the repository root inside the runtime |
scope | string | No | local (default), remote (git branch -r), or all (git branch -a) |
Response
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the git command completed successfully |
exit_code | integer | Process exit code from git |
stdout | string | Branch listing from git |
stderr | string | Standard error from git |
error | string | Error message when the operation fails |