Skip to main content
Glama

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
NameRequiredDescriptionDefault
interactiveNoWhether to perform an interactive rebase
ontoYesBranch or commit to rebase onto
repo_pathYesThe 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, }; } }
  • 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,
  • 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,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bsreeram08/git-commands-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server