Skip to main content
Glama

git_rebase

Rebase a Git branch onto another branch or commit to integrate changes while maintaining a linear project history.

Instructions

Rebase the current branch onto another branch or commit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
ontoYesBranch or commit to rebase onto
interactiveNoWhether to perform an interactive rebase

Implementation Reference

  • Main handler function that executes the git rebase logic using simpleGit library. Handles non-interactive rebases and returns formatted results or errors.
    /** * Handles git rebase operations * @param {string} repoPath - Path to the local repository * @param {string} onto - Branch or commit to rebase onto * @param {boolean} interactive - Whether to perform an interactive rebase * @returns {Object} - Rebase result */ 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, }; } }
  • Input schema and description for the git_rebase tool, defining parameters repo_path (required), onto (required), and interactive (optional boolean).
    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:915-927 (registration)
    Registration of git_rebase handler in the central handlersMap object used for tool dispatching.
    git_create_tag: handleGitCreateTag, git_rebase: handleGitRebase, git_config: handleGitConfig, git_reset: handleGitReset, git_archive: handleGitArchive, git_attributes: handleGitAttributes, git_blame: handleGitBlame, git_clean: handleGitClean, git_hooks: handleGitHooks, git_lfs: handleGitLFS, git_lfs_fetch: handleGitLFSFetch, git_revert: handleGitRevert, };
  • Re-export of handleGitRebase from advanced-operations.js for centralized import in server.js.
    handleGitRebase, handleGitReset,
  • src/server.js:27-27 (registration)
    Import of handleGitRebase handler into server.js from handlers/index.js.
    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