Skip to main content
Glama

git-reset

Reset Git repository state to undo changes, move HEAD to specific commits, or restore branches using soft, mixed, or hard reset operations with safety controls for destructive actions.

Instructions

Git reset tool for repository state management. Supports soft, mixed, hard reset capabilities and reset-to-commit and reset-branch functionality. Includes safety warnings for destructive operations like hard reset.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesThe reset operation to perform
branchNoBranch name (required for reset-branch operation)
commitNoCommit hash or reference (required for reset-to-commit, optional for others)
confirmDestructiveNoExplicit confirmation for destructive operations (required for hard reset)
filesNoSpecific files to reset (for mixed/soft resets)
forceNoForce reset - required for hard reset operations
projectPathYesAbsolute path to the project directory
quietNoSuppress output during reset operation
skipWarningNoSkip safety warnings (use with extreme caution - not recommended)

Implementation Reference

  • Main handler implementation: GitResetTool.execute() method that orchestrates parameter validation, safety warnings, repository checks, and dispatches to specific reset operations (soft, mixed, hard, reset-to-commit, reset-branch).
    async execute(params: GitResetParams): Promise<ToolResult> {
      const startTime = Date.now();
    
      try {
        // Validate basic parameters
        const validation = ParameterValidator.validateToolParams('git-reset', params);
        if (!validation.isValid) {
          return OperationErrorHandler.createToolError(
            'VALIDATION_ERROR',
            `Parameter validation failed: ${validation.errors.join(', ')}`,
            params.action,
            { validationErrors: validation.errors },
            validation.suggestions
          );
        }
    
        // Validate operation-specific parameters
        const operationValidation = this.validateOperationParams(params);
        if (!operationValidation.isValid) {
          return OperationErrorHandler.createToolError(
            'VALIDATION_ERROR',
            `Operation validation failed: ${operationValidation.errors.join(', ')}`,
            params.action,
            { validationErrors: operationValidation.errors },
            operationValidation.suggestions
          );
        }
    
        // Check for destructive operations and show safety warnings
        if (!params.skipWarning) {
          const warningResult = this.checkSafetyWarnings(params);
          if (warningResult) {
            return warningResult;
          }
        }
    
        // Check if it's a Git repository
        const isRepo = await this.gitExecutor.isGitRepository(params.projectPath);
        if (!isRepo) {
          return OperationErrorHandler.createToolError(
            'NOT_A_GIT_REPOSITORY',
            'The specified path is not a Git repository',
            params.action,
            { projectPath: params.projectPath },
            ['Initialize a Git repository first with: git init']
          );
        }
    
        // Route to appropriate handler
        switch (params.action) {
          case 'soft':
            return await this.handleSoftReset(params, startTime);
          case 'mixed':
            return await this.handleMixedReset(params, startTime);
          case 'hard':
            return await this.handleHardReset(params, startTime);
          case 'reset-to-commit':
            return await this.handleResetToCommit(params, startTime);
          case 'reset-branch':
            return await this.handleResetBranch(params, startTime);
          default:
            return OperationErrorHandler.createToolError(
              'UNSUPPORTED_OPERATION',
              `Operation '${params.action}' is not supported`,
              params.action,
              {},
              ['Use one of: soft, mixed, hard, reset-to-commit, reset-branch']
            );
        }
    
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        return OperationErrorHandler.createToolError(
          'EXECUTION_ERROR',
          `Failed to execute ${params.action}: ${errorMessage}`,
          params.action,
          { error: errorMessage },
          ['Check the error details and try again']
        );
      }
    }
  • Tool schema definition including name, description, and detailed inputSchema with all parameters (action enum, projectPath required, optional commit/branch/files/force/quiet/skipWarning/confirmDestructive).
    static getToolSchema() {
      return {
        name: 'git-reset',
        description: 'Git reset tool for repository state management. Supports soft, mixed, hard reset capabilities and reset-to-commit and reset-branch functionality. Includes safety warnings for destructive operations like hard reset.',
        inputSchema: {
          type: 'object',
          properties: {
            action: {
              type: 'string',
              enum: ['soft', 'mixed', 'hard', 'reset-to-commit', 'reset-branch'],
              description: 'The reset operation to perform'
            },
            projectPath: {
              type: 'string',
              description: 'Absolute path to the project directory'
            },
            commit: {
              type: 'string',
              description: 'Commit hash or reference (required for reset-to-commit, optional for others)'
            },
            branch: {
              type: 'string',
              description: 'Branch name (required for reset-branch operation)'
            },
            files: {
              type: 'array',
              items: { type: 'string' },
              description: 'Specific files to reset (for mixed/soft resets)'
            },
            force: {
              type: 'boolean',
              description: 'Force reset - required for hard reset operations'
            },
            quiet: {
              type: 'boolean',
              description: 'Suppress output during reset operation'
            },
            skipWarning: {
              type: 'boolean',
              description: 'Skip safety warnings (use with extreme caution - not recommended)'
            },
            confirmDestructive: {
              type: 'boolean',
              description: 'Explicit confirmation for destructive operations (required for hard reset)'
            }
          },
          required: ['action', 'projectPath']
        }
      };
    }
  • src/server.ts:133-133 (registration)
    Tool schema registration in ListToolsRequestSchema handler: GitResetTool.getToolSchema() included in the returned tools array.
    GitResetTool.getToolSchema(),
  • src/server.ts:486-487 (registration)
    Tool dispatch registration in CallToolRequestSchema's executeTool switch: maps 'git-reset' name to this.gitResetTool.execute(args).
    case 'git-reset':
      return await this.gitResetTool.execute(args);
  • src/server.ts:97-97 (registration)
    Instantiation of GitResetTool instance during server initialization with provider configuration.
    this.gitResetTool = new GitResetTool(providerConfig);
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively adds context by warning about 'destructive operations like hard reset,' which informs the agent about potential data loss. However, it lacks details on rate limits, authentication needs, or specific error conditions, leaving some behavioral aspects uncovered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with two sentences that efficiently convey purpose, capabilities, and safety warnings. Every sentence earns its place by adding value without redundancy, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (9 parameters, no output schema, no annotations), the description is reasonably complete. It covers the core purpose and safety aspects, but could improve by addressing output behavior or error handling. Without annotations or output schema, the description does a solid job but has minor gaps in full contextual coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents all 9 parameters thoroughly. The description adds minimal value beyond the schema by hinting at parameter usage (e.g., 'hard reset capabilities'), but doesn't provide additional syntax or format details. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'Git reset tool for repository state management' with specific capabilities listed (soft, mixed, hard reset, reset-to-commit, reset-branch). It distinguishes from sibling tools like git-branches or git-stash by focusing specifically on reset operations rather than branch management or stashing functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the mention of 'safety warnings for destructive operations like hard reset,' suggesting when caution is needed. However, it doesn't explicitly state when to use this tool versus alternatives (e.g., git-stash for temporary changes or git-branches for branch operations), nor does it provide clear exclusions or prerequisites beyond the safety note.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Andre-Buzeli/git-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server