Skip to main content
All standard Git operations are supported. Use with WarpGrep for fast code search.

Basic Workflow

import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: "YOUR_API_KEY" });

// Initialize
await morph.git.init({ repoId: 'my-project', dir: './my-project' });

// Clone
await morph.git.clone({ repoId: 'my-project', dir: './local-copy' });

// Stage and commit
await morph.git.add({ dir: './my-project', filepath: '.' });
await morph.git.commit({ 
  dir: './my-project', 
  message: 'Add feature'
});

// Push to remote
await morph.git.push({ dir: './my-project' });
After pushing, search your code instantly with WarpGrep—no indexing required.

Repository Management

Initialize Repository

await morph.git.init({ 
  repoId: 'my-project', 
  dir: './my-project' 
});
Initialize a new repository. The repoId uniquely identifies your project across the Morph platform.

Clone Repository

await morph.git.clone({ 
  repoId: 'my-project', 
  dir: './local-copy' 
});
Clone an existing repository to a new directory. Useful for multi-workspace setups or agent deployments.

Staging and Committing

Stage Changes

// Stage specific file
await morph.git.add({ 
  dir: './my-project', 
  filepath: 'src/auth.ts' 
});

// Stage all changes
await morph.git.add({ 
  dir: './my-project', 
  filepath: '.' 
});
Stage files for commit. Use . to stage all changes in the repository.

Commit Changes

await morph.git.commit({ 
  dir: './my-project', 
  message: 'Implement OAuth authentication'
});

// With metadata
await morph.git.commit({
  dir: './my-project',
  message: 'Fix bug',
  metadata: { issueId: 'BUG-123', priority: 'high' },
  chatHistory: [...],  // Optional: AI conversation history
  recordingId: 'rec_abc'  // Optional: Browser recording ID
});
Commit staged changes with a descriptive message. You can attach arbitrary metadata, chat history, and recording IDs. See Agent Metadata for more details.

Syncing Changes

Push Changes

await morph.git.push({ dir: './my-project', branch: 'main' });
Push commits to remote. After pushing, use WarpGrep to search your code instantly.

Pull Changes

await morph.git.pull({ dir: './my-project' });
Pull latest changes from remote. Useful in collaborative or multi-agent environments.

Status and History

Check Status

// Simple status
const status = await morph.git.status({ 
  dir: './my-project', 
  filepath: 'src/auth.ts' 
});

// Detailed status matrix
const files = await morph.git.statusMatrix({ dir: './my-project' });
files.forEach(f => console.log(f.filepath, f.status));
Get file status to see what’s changed, staged, or committed.

View History

const commits = await morph.git.log({ 
  dir: './my-project', 
  depth: 10 
});

commits.forEach(commit => {
  console.log(commit.oid, commit.commit.message);
});
View commit history. Use depth to limit how many commits are returned.

Branch Management

Create Branch

await morph.git.branch({ 
  dir: './my-project', 
  name: 'feature-branch' 
});
Create a new branch without checking it out.

List Branches

const branches = await morph.git.listBranches({ dir: './my-project' });
console.log('Branches:', branches);
Get all branches in the repository.

Get Current Branch

const current = await morph.git.currentBranch({ dir: './my-project' });
console.log('Current branch:', current);
Get the name of the currently checked out branch.

Checkout Branch

// Checkout existing branch
await morph.git.checkout({ 
  dir: './my-project', 
  ref: 'main' 
});

// Checkout specific commit
await morph.git.checkout({ 
  dir: './my-project', 
  ref: 'abc123...' 
});
Switch branches or checkout a specific commit.

Advanced Operations

Resolve Reference

const sha = await morph.git.resolveRef({ 
  dir: './my-project', 
  ref: 'HEAD' 
});
console.log('Current commit:', sha);
Get the commit hash for any reference (branch name, tag, HEAD, etc.).

Searching Your Code

After pushing, use WarpGrep to search your code with natural language queries. No indexing or setup required.
// Search with natural language
const results = await morph.warpGrep.execute({
  query: 'Find authentication middleware',
  repoRoot: './my-project'
});

if (results.success) {
  for (const ctx of results.contexts) {
    console.log(`${ctx.file}:`);
    console.log(ctx.content);
  }
}
See WarpGrep for full search documentation.

All Methods

MethodDescription
init(options)Initialize new repository
clone(options)Clone existing repository
add(options)Stage file for commit
commit(options)Commit staged changes with optional metadata
push(options)Push to remote
pull(options)Pull from remote
status(options)Get file status
statusMatrix(options)Get all file statuses
log(options)Get commit history
checkout(options)Checkout branch or commit
branch(options)Create new branch
listBranches(options)List all branches
currentBranch(options)Get current branch name
resolveRef(options)Get commit hash for ref
getCommitMetadata(options)Get metadata, chat history, and recording ID for a commit