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
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Reset mode (soft, mixed, hard) | mixed |
| repo_path | Yes | The path to the local Git repository | |
| to | No | Commit or reference to reset to | HEAD |
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, }; } }
- src/server.js:595-618 (schema)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,
- src/handlers/index.js:27-27 (registration)Imports handleGitReset from advanced-operations.js into the handlers index for re-export.import { handleGitRebase, handleGitReset } from "./advanced-operations.js";