POST /v1/agents/runtime/{runtime_id}/git/commit
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",
)
sandbox.file.write("/workspace/repo/note.txt", "hello\n")
sandbox.git.add("/workspace/repo", paths=["note.txt"])
r = sandbox.git.commit(
"/workspace/repo",
"add note",
author_name="Demo",
author_email="demo@example.com",
)
print(r.success, 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');
await sandbox.file.write("/workspace/repo/note.txt", "hello\n");
await sandbox.git.add('/workspace/repo', ['note.txt']);
const r = await sandbox.git.commit('/workspace/repo', 'add note', {
authorName: 'Demo',
authorEmail: 'demo@example.com',
});
console.log(r.success, r.stdout);
await sandbox.kill();
await client.networkPolicies.delete(policy.id);
gravixlayer runtime git commit "$RT" \
--path /workspace/repo \
-m "add note" \
--author-name Demo \
--author-email demo@example.com
curl -X POST "https://api.gravixlayer.ai/v1/agents/runtime/$RT/git/commit" \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"repository_path": "/workspace/repo",
"message": "add note",
"author_name": "Demo",
"author_email": "demo@example.com"
}'
author_name and author_email apply to this commit alone and do not change the
repository’s configuration. Supply both: a fresh runtime usually has no
user.email configured, and git refuses to commit without one.
Committing with nothing staged fails unless allow_empty is true.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
repository_path | string | Yes | Path to the repository root inside the runtime |
message | string | Yes | Commit message |
author_name | string | No | Author name for the commit |
author_email | string | No | Author email for the commit |
allow_empty | boolean | No | Allow a commit with no changes |
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 |