git_rebase
Rebase the current branch onto a specified branch or commit to streamline Git history. Configure interactive mode for precise control over commit adjustments.
Instructions
Rebase the current branch onto another branch or commit.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| interactive | No | Whether to perform an interactive rebase | |
| onto | Yes | Branch or commit to rebase onto | |
| repo_path | Yes | The path to the local Git repository |
Implementation Reference
- The core handler function implementing git_rebase tool logic, performing non-interactive rebase using simpleGit and handling errors.export async function handleGitRebase({ repo_path, onto, interactive = false, }) { try { // For interactive rebase, we need to use exec as simple-git doesn't support it well if (interactive) { return { content: [ { type: "text", text: JSON.stringify( { error: "Interactive rebase not supported through API" }, null, 2 ), }, ], isError: true, }; } const git = simpleGit(repo_path); const rebaseResult = await git.rebase([onto]); return { content: [ { type: "text", text: JSON.stringify( { success: true, message: `Rebased onto ${onto}`, result: rebaseResult, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: `Failed to rebase: ${error.message}`, conflicts: error.git ? error.git.conflicts : null, }, null, 2 ), }, ], isError: true, }; } }
- src/server.js:540-561 (schema)Defines the tool metadata including name, description, and input schema validation for git_rebase.name: "git_rebase", description: "Rebase the current branch onto another branch or commit.", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "The path to the local Git repository", }, onto: { type: "string", description: "Branch or commit to rebase onto", }, interactive: { type: "boolean", description: "Whether to perform an interactive rebase", default: false, }, }, required: ["repo_path", "onto"], }, },
- src/server.js:916-916 (registration)Maps the 'git_rebase' tool name to its handler function in the central handlersMap.git_rebase: handleGitRebase,
- src/handlers/index.js:27-27 (registration)Imports the handleGitRebase function from advanced-operations.js for re-export.import { handleGitRebase, handleGitReset } from "./advanced-operations.js";
- src/server.js:27-27 (registration)Imports handleGitRebase from handlers/index.js in the main server file.handleGitRebase,