Skip to main content
Glama

git_reset

Reset a Git repository to a specific commit or state using specified modes (soft, mixed, hard). Manage repository history and restore previous states easily on the Git Repo Browser MCP server.

Instructions

Reset repository to specified commit or state.

Input Schema

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

Implementation Reference

  • The core handler function that executes the git reset operation using simpleGit.reset() with specified mode (soft, mixed, hard) and target commit.
    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, }; } }
  • Defines the tool schema including name, description, and input schema for git_reset with repo_path (required), mode (enum: soft/mixed/hard, 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)
    Registers the 'git_reset' tool name to the handleGitReset handler function in the handlersMap.
    git_reset: handleGitReset,
  • src/server.js:29-29 (registration)
    Imports the handleGitReset function from handlers/index.js for use in server.js.
    handleGitReset,
  • Imports handleGitReset from advanced-operations.js into the handlers index for re-export.
    import { handleGitRebase, handleGitReset } from "./advanced-operations.js";

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