Skip to main content
Glama

push

Push commits and tags to a remote Git repository, optionally force-pushing changes or skipping pre-push hooks, using the Git MCP Server for enhanced Git operations.

Instructions

Push commits to remote

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchYesBranch name
forceNoForce push changes
noVerifyNoSkip pre-push hooks
pathNoPath to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo)
remoteNoRemote nameorigin
tagsNoPush all tags

Implementation Reference

  • Primary handler function for the 'push' tool. Validates inputs, executes 'git push' command with options, handles caching and errors.
    static async push({ path, remote = 'origin', branch, force, noVerify, tags }: PushPullOptions, context: GitToolContext): Promise<GitToolResult> { const resolvedPath = this.getPath({ path }); return await this.executeOperation( context.operation, resolvedPath, async () => { const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath); await RepositoryValidator.validateRemoteConfig(repoPath, remote, context.operation); await RepositoryValidator.validateBranchExists(repoPath, branch, context.operation); const result = await CommandExecutor.executeGitCommand( `push ${remote} ${branch}${force ? ' --force' : ''}${noVerify ? ' --no-verify' : ''}${tags ? ' --tags' : ''}`, context.operation, repoPath ); return { content: [{ type: 'text', text: `Changes pushed successfully\n${CommandExecutor.formatOutput(result)}` }] }; }, { command: 'push', invalidateCache: true, // Invalidate remote cache stateType: RepoStateType.REMOTE } ); }
  • Registers the 'push' tool in the MCP server's ListTools handler, defining name, description, and input schema.
    { name: 'push', description: 'Push commits to remote', inputSchema: { type: 'object', properties: { path: { type: 'string', description: `Path to repository. ${PATH_DESCRIPTION}`, }, remote: { type: 'string', description: 'Remote name', default: 'origin', }, branch: { type: 'string', description: 'Branch name', }, force: { type: 'boolean', description: 'Force push changes', default: false }, noVerify: { type: 'boolean', description: 'Skip pre-push hooks', default: false }, tags: { type: 'boolean', description: 'Push all tags', default: false } }, required: ['branch'], }, },
  • TypeScript interface defining the input parameters for push/pull operations, used for type checking and validation.
    export interface PushPullOptions extends GitOptions, BasePathOptions { remote?: string; branch: string; force?: boolean; // Allow force push/pull noVerify?: boolean; // Skip pre-push/pre-pull hooks tags?: boolean; // Include tags }
  • Dispatches 'push' tool calls to GitOperations.push after argument validation.
    case 'push': { const validArgs = this.validateArguments(operation, args, isPushPullOptions); return await GitOperations.push(validArgs, context); }
  • Type guard function used to validate push/pull options before execution.
    export function isPushPullOptions(obj: any): obj is PushPullOptions { return obj && validatePath(obj.path) && typeof obj.branch === 'string'; }

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/Sheshiyer/git-mcp-v2'

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