Skip to main content
Glama

git_reset

Reset a Git repository to a specific commit or state using soft, mixed, or hard reset modes to undo changes and restore previous versions.

Instructions

Reset repository to specified commit or state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesThe path to the local Git repository
modeNoReset mode (soft, mixed, hard)mixed
toNoCommit or reference to reset toHEAD

Implementation Reference

  • Main handler function that performs git reset (soft, mixed, hard) to a specified commit or HEAD using simpleGit.
    export async function handleGitReset({ repo_path, mode = "mixed", to = "HEAD", }) { try { const git = simpleGit(repo_path); // Check valid mode if (!["soft", "mixed", "hard"].includes(mode)) { return { content: [ { type: "text", text: JSON.stringify( { error: `Invalid reset mode: ${mode}. Use 'soft', 'mixed', or 'hard'.`, }, null, 2 ), }, ], isError: true, }; } // Perform the reset await git.reset([`--${mode}`, to]); return { content: [ { type: "text", text: JSON.stringify( { success: true, message: `Reset (${mode}) to ${to}`, mode: mode, target: to, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: `Failed to reset repository: ${error.message}` }, null, 2 ), }, ], isError: true, }; } }
  • Tool schema definition including input parameters repo_path (required), mode (default mixed), and to (default HEAD).
    name: "git_reset", description: "Reset repository to specified commit or state.", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "The path to the local Git repository", }, mode: { type: "string", description: "Reset mode (soft, mixed, hard)", default: "mixed", enum: ["soft", "mixed", "hard"], }, to: { type: "string", description: "Commit or reference to reset to", default: "HEAD", }, }, required: ["repo_path"], }, },
  • src/server.js:918-918 (registration)
    Maps the 'git_reset' tool name to the handleGitReset handler function in the server's handlersMap.
    git_reset: handleGitReset,
  • Re-exports handleGitReset from advanced-operations.js for use in server.js.
    handleGitReset,

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