Skip to main content
Glama

git_pull

Pull updates from a remote Git repository, specify branch and rebase options, and sync local code with the latest changes. Ideal for managing repository versions and maintaining up-to-date working copies.

Instructions

Pull changes from a remote repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNoBranch to pull (default: current branch)
rebaseNoWhether to rebase instead of merge
remoteNoRemote nameorigin
repo_pathYesThe path to the local Git repository

Implementation Reference

  • Core implementation of the git_pull tool handler. Performs git pull using simpleGit, supports repo_path, remote, branch, and rebase options. Returns structured MCP response with success/error details.
    export async function handleGitPull({ repo_path, remote = "origin", branch = null, rebase = false, }) { try { const git = simpleGit(repo_path); // If no branch specified, use current branch if (!branch) { const branchInfo = await git.branch(); branch = branchInfo.current; } // Set up pull options const pullOptions = {}; if (rebase) { pullOptions["--rebase"] = null; } // Perform the pull const pullResult = await git.pull(remote, branch, pullOptions); return { content: [ { type: "text", text: JSON.stringify( { success: true, result: pullResult, message: `Pulled from ${remote}/${branch}`, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { error: `Failed to pull changes: ${error.message}`, conflicts: error.git ? error.git.conflicts : null, }, null, 2 ), }, ], isError: true, }; }
  • Input schema definition for the git_pull tool, defining parameters and validation rules in the server's toolsList.
    { name: "git_pull", description: "Pull changes from a remote repository.", inputSchema: { type: "object", properties: { repo_path: { type: "string", description: "The path to the local Git repository", }, remote: { type: "string", description: "Remote name", default: "origin", }, branch: { type: "string", description: "Branch to pull (default: current branch)", }, rebase: { type: "boolean", description: "Whether to rebase instead of merge", default: false, }, }, required: ["repo_path"], }, },
  • src/server.js:913-913 (registration)
    Registration of 'git_pull' tool name mapped to handleGitPull function in the server's handlersMap for request handling.
    git_pull: handleGitPull,
  • Re-export of handleGitPull from remote-operations.js in handlers index for centralized import in server.js.
    handleGitPush, handleGitPull, handleGitRemote,
  • Helper module re-exporting simpleGit library used by handleGitPull for executing git pull command.
    import { simpleGit } from "simple-git"; import { exec } from "child_process"; import { promisify } from "util"; import { cloneRepo, getDirectoryTree } from "../utils/git.js"; const execPromise = promisify(exec); export { path, fs, simpleGit, execPromise, cloneRepo, getDirectoryTree };

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/bsreeram08/git-commands-mcp'

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