git_commit
Create a Git commit with a specified message to save changes in a repository. This tool helps track project progress by recording modifications with descriptive messages.
Instructions
Create a commit with the specified message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_path | Yes | The path to the local Git repository | |
| message | Yes | The commit message |
Implementation Reference
- The handler function that executes the git_commit tool: creates a commit in the specified repository using simpleGit.commit() on staged changes.* Creates a commit with the specified message * @param {string} repoPath - Path to the local repository * @param {string} message - Commit message * @returns {Object} - Commit result */ export async function handleGitCommit({ repo_path, message }) { try { const git = simpleGit(repo_path); // Create the commit (only commit what's in the staging area) const commitResult = await git.commit(message); return { content: [ { type: "text", text: JSON.stringify( { success: true, commit_hash: commitResult.commit, commit_message: message, summary: commitResult.summary, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: `Failed to create commit: ${error.message}` }, null, 2 ), }, ], isError: true, }; } }
- src/server.js:332-348 (schema)JSON schema definition for the git_commit tool input parameters (repo_path and message).name: "git_commit", description: "Create a commit with the specified message.", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "The path to the local Git repository", }, message: { type: "string", description: "The commit message", }, }, required: ["repo_path", "message"], }, },
- src/server.js:907-907 (registration)Maps the tool name 'git_commit' to its handler function handleGitCommit in the central handlersMap.git_commit: handleGitCommit,
- src/handlers/index.js:51-51 (registration)Re-exports the handleGitCommit handler from commit-operations.js for use in server.js.handleGitCommit,
- src/handlers/index.js:9-13 (registration)Imports the handleGitCommit function from the commit-operations module.handleGitCommitHistory, handleGitCommitsDetails, handleGitCommit, handleGitTrack, } from "./commit-operations.js";