POST /v1/agents/runtime/{runtime_id}/git/branch/create
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",
)
r = sandbox.git.create_branch("/workspace/repo", "feature-x")
print(r.success, r.exit_code)
# Optional: create from a start point (commit or branch name)
r = sandbox.git.create_branch(
"/workspace/repo", "feature-y", start_point="master"
)
print(r.success)
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');
const r = await sandbox.git.createBranch("/workspace/repo", "feature-x");
console.log(r.success, r.exitCode);
// Optional: create from a start point (commit or branch name)
let fromMaster = await sandbox.git.createBranch('/workspace/repo', 'feature-y', 'master');
console.log(fromMaster.success);
await sandbox.kill();
await client.networkPolicies.delete(policy.id);
gravixlayer runtime git branch-create "$RT" feature-x --path /workspace/repo
# From a start point
gravixlayer runtime git branch-create "$RT" feature-y \
--path /workspace/repo \
--start-point master
curl -X POST "https://api.gravixlayer.ai/v1/agents/runtime/$RT/git/branch/create" \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"repository_path": "/workspace/repo",
"branch_name": "feature-y",
"start_point": "master"
}'
git branch. Follow
with checkout to switch.
Without start_point, the branch starts at the current HEAD.
Branch names may not begin with - or contain ...
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
repository_path | string | Yes | Path to the repository root inside the runtime |
branch_name | string | Yes | Name of the new branch |
start_point | string | No | Commit, branch, or tag to branch from |
Response
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the git command completed successfully |
exit_code | integer | Process exit code from git |
stdout | string | Standard output from git |
stderr | string | Standard error from git |
error | string | Error message when the operation fails |