Ctrl + K

Git Commits

Stage files, create commits, and push changes to remote repositories.

Stage Files

Add files to the staging area:

// Stage specific files
await sandbox.git.add({
  repoPath: '/opt/app',
  files: ['src/index.js', 'package.json']
});

// Stage all changes
await sandbox.git.add({
  repoPath: '/opt/app',
  files: ['.']
});
await fetch(`${sandbox.url}/git/add`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    files: ['.']
  })
});
curl -X POST https://sandbox.oblien.com/git/add \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json"

Response:

{
  "success": true,
  "message": "Files added to staging area",
  "filesAdded": 2
}

Create Commit

Commit staged changes:

await sandbox.git.commit({
  repoPath: '/opt/app',
  message: 'Add new feature',
  author: {
    name: 'AI Agent',
    email: 'ai@oblien.com'
  }
});
await fetch(`${sandbox.url}/git/commit`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    message: 'Add new feature',
    author: {
      name: 'AI Agent',
      email: 'ai@oblien.com'
    }
  })
});
curl -X POST https://sandbox.oblien.com/git/commit \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json"

Response:

{
  "success": true,
  "message": "Changes committed successfully",
  "commit": "a1b2c3d4",
  "branch": "main"
}

Push to Remote

Push commits to remote repository:

await sandbox.git.push({
  repoPath: '/opt/app',
  branch: 'main',
  auth: {
    type: 'token',
    token: process.env.GITHUB_TOKEN
  }
});

// Force push (use with caution)
await sandbox.git.push({
  repoPath: '/opt/app',
  branch: 'feature-branch',
  force: true,
  auth: {
    type: 'token',
    token: process.env.GITHUB_TOKEN
  }
});
await fetch(`${sandbox.url}/git/push`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    branch: 'main',
    auth: {
      type: 'token',
      token: process.env.GITHUB_TOKEN
    }
  })
});
curl -X POST https://sandbox.oblien.com/git/push \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json"

Response:

{
  "success": true,
  "message": "Changes pushed to remote",
  "branch": "main",
  "remote": "origin"
}

Pull from Remote

Pull latest changes from remote:

await sandbox.git.pull({
  repoPath: '/opt/app',
  branch: 'main',
  auth: {
    type: 'token',
    token: process.env.GITHUB_TOKEN
  }
});
await fetch(`${sandbox.url}/git/pull`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    branch: 'main',
    auth: {
      type: 'token',
      token: process.env.GITHUB_TOKEN
    }
  })
});
curl -X POST https://sandbox.oblien.com/git/pull \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json"

View Commit History

const history = await sandbox.git.history({
  repoPath: '/opt/app',
  limit: 10
});

history.commits.forEach(commit => {
  console.log(`${commit.hash} - ${commit.message}`);
  console.log(`  Author: ${commit.author}`);
  console.log(`  Date: ${commit.date}`);
});
const response = await fetch(`${sandbox.url}/git/history`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    limit: 10
  })
});

const history = await response.json();
curl -X POST https://sandbox.oblien.com/git/history \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json"

Response:

{
  "success": true,
  "commits": [
    {
      "hash": "a1b2c3d4",
      "message": "Add new feature",
      "author": "AI Agent <ai@oblien.com>",
      "date": "2025-10-26T12:00:00Z",
      "branch": "main"
    }
  ]
}

Complete Workflow

// Make file changes
await sandbox.files.edit({
  filePath: '/opt/app/src/api.js',
  content: '// Updated API code'
});

await sandbox.files.create({
  fullPath: '/opt/app/src/utils.js',
  content: '// New utility functions'
});

// Check status
const status = await sandbox.git.status({
  repoPath: '/opt/app'
});
console.log('Modified:', status.modified);
console.log('Untracked:', status.untracked);

// Stage changes
await sandbox.git.add({
  repoPath: '/opt/app',
  files: ['.']
});

// Commit
await sandbox.git.commit({
  repoPath: '/opt/app',
  message: 'Refactor API and add utilities',
  author: {
    name: 'AI Agent',
    email: 'ai@oblien.com'
  }
});

// Push to remote
await sandbox.git.push({
  repoPath: '/opt/app',
  branch: 'main',
  auth: {
    type: 'token',
    token: process.env.GITHUB_TOKEN
  }
});
// (Make file changes)

// Check status
let response = await fetch(`${sandbox.url}/git/status`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ repoPath: '/opt/app' })
});

// Stage changes
await fetch(`${sandbox.url}/git/add`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    files: ['.']
  })
});

// Commit
await fetch(`${sandbox.url}/git/commit`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    message: 'Refactor API and add utilities',
    author: {
      name: 'AI Agent',
      email: 'ai@oblien.com'
    }
  })
});

// Push
await fetch(`${sandbox.url}/git/push`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${sandbox.token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    repoPath: '/opt/app',
    branch: 'main',
    auth: {
      type: 'token',
      token: process.env.GITHUB_TOKEN
    }
  })
});
curl -X POST https://sandbox.oblien.com/git/status \
  -H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
  -H "Content-Type: application/json"

Parameters

Add (Stage)

ParameterTypeRequiredDescription
repoPathstringYesRepository path
filesstring[]YesFiles to stage (use ['.'] for all)

Commit

ParameterTypeRequiredDescription
repoPathstringYesRepository path
messagestringYesCommit message
authorobjectNoAuthor info {name, email}

Push

ParameterTypeRequiredDescription
repoPathstringYesRepository path
branchstringNoBranch to push
forcebooleanNoForce push
authobjectNoAuthentication config

Pull

ParameterTypeRequiredDescription
repoPathstringYesRepository path
branchstringNoBranch to pull
authobjectNoAuthentication config

Best Practices

  1. Write descriptive commit messages:

    message: 'Add user authentication with JWT'
    // Not: 'Update files'
  2. Check status before committing: Review changes before staging

  3. Stage specific files: Avoid staging unrelated changes

  4. Configure author info: Always set name and email

  5. Pull before push: Get latest changes to avoid conflicts

Next Steps