Skip to main content
Glama

git_log

View commit logs for Git repositories to track changes, filter by count, and customize output format, enabling efficient version control management.

Instructions

Shows the commit logs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNo
graphNo
max_countNo
onelineNo
repo_pathYes

Implementation Reference

  • Core handler function that executes `git log` using GitPython Repo.git.log with parameters max_count, oneline, graph, format_str.
    def git_log( repo: Repo, max_count: int = 10, oneline: bool = False, graph: bool = False, format_str: str | None = None, # Renamed from 'format' ) -> str: """Get commit history with formatting options""" try: args = [] if max_count: args.extend(["-n", str(max_count)]) if oneline: args.append("--oneline") elif format_str: # Use format_str args.extend(["--pretty=format:" + format_str]) if graph: args.append("--graph") # Get commit log log_output = repo.git.log(*args) if not log_output.strip(): return "No commits found in repository" return log_output except GitCommandError as e: return f"❌ Log failed: {str(e)}" except Exception as e: return f"❌ Log error: {str(e)}"
  • Pydantic model defining input schema for git_log tool: repo_path (required), max_count (default 10), oneline, graph, format.
    class GitLog(BaseModel): repo_path: str max_count: int = 10 oneline: bool = False graph: bool = False format: str | None = None
  • Registers the git_log tool in the ToolRegistry with name 'git_log', GitLog schema, placeholder handler (later overridden), requires repo.
    name=GitTools.LOG, category=ToolCategory.GIT, description="Show the commit logs", schema=GitLog, handler=placeholder_handler, requires_repo=True, ),
  • Maps 'git_log' tool name to wrapper handler created by _create_git_handler, which loads Repo from repo_path and calls git_log from operations.py with extra args.
    git_log, requires_repo=True, extra_args=["max_count", "oneline", "graph", "format"], ), "git_create_branch": self._create_git_handler( git_create_branch, requires_repo=True, extra_args=["branch_name", "base_branch"], ), "git_checkout": self._create_git_handler( git_checkout, requires_repo=True, extra_args=["branch_name"] ), "git_show": self._create_git_handler( git_show, requires_repo=True, extra_args=["revision"] ), "git_init": self._create_git_init_handler(git_init), "git_push": self._create_git_handler( git_push, requires_repo=True, extra_args=["remote", "branch", "set_upstream", "force"], ), "git_pull": self._create_git_handler( git_pull, requires_repo=True, extra_args=["remote", "branch"] ), "git_diff_branches": self._create_git_handler( git_diff_branches, requires_repo=True, extra_args=["base_branch", "compare_branch"], ), "git_rebase": self._create_git_handler( git_rebase, requires_repo=True, extra_args=["target_branch"], ), "git_merge": self._create_git_handler( git_merge, requires_repo=True, extra_args=["source_branch", "strategy", "message"], ), "git_cherry_pick": self._create_git_handler( git_cherry_pick, requires_repo=True, extra_args=["commit_hash", "no_commit"], ), "git_abort": self._create_git_handler( git_abort, requires_repo=True, extra_args=["operation"] ), "git_continue": self._create_git_handler( git_continue, requires_repo=True, extra_args=["operation"] ), }
  • Protected wrapper for git_log that validates repository binding and remote integrity before calling core git_log.
    async def protected_git_log(self, repo_path: str, max_count: int = 10) -> str: """Git log with repository binding protection.""" validated_path = await self._validate_and_prepare_operation(repo_path) repo = Repo(validated_path) return git_log(repo, max_count)

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

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