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
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | The path to the local Git repository | |
| mode | No | Reset mode (soft, mixed, hard) | mixed |
| to | No | Commit or reference to reset to | HEAD |
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, }; } }
- src/server.js:595-618 (schema)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,
- src/handlers/index.js:73-73 (registration)Re-exports handleGitReset from advanced-operations.js for use in server.js.handleGitReset,