SDK: Git
The Git client provides methods for managing Git providers, repositories, branches, commits, and pull requests through the platform.
Access it via client.git.
Provider Management
// Register a Git provider
const provider = await client.git.providers.create({
name: "github-org",
type: "github",
token: process.env.GITHUB_TOKEN,
});
// List providers
const providers = await client.git.providers.list();
// Remove a provider
await client.git.providers.remove(provider.id);
Repository Operations
// Connect a repository
const repo = await client.git.repos.connect({
providerId: provider.id,
owner: "the-shift-dev",
name: "platform",
});
// List connected repositories
const repos = await client.git.repos.list();
// Get repository details
const details = await client.git.repos.get(repo.id);
Branch Operations
// List branches
const branches = await client.git.branches.list(repo.id);
// Get branch details
const branch = await client.git.branches.get(repo.id, "main");
Commits
// List recent commits
const commits = await client.git.commits.list(repo.id, {
branch: "main",
limit: 10,
});
File Operations
// Read a file from a branch
const file = await client.git.files.read(repo.id, "main", "package.json");
Notes
- The Git service is experimental. For day-to-day app scaffolding,
shift-cli create-appwithghCLI and Stage repository linkage is the recommended path. - Provider tokens are stored securely and never returned in API responses after creation.