Skip to content

[git] Get parent branch and diff since it (suggestion included) #1614

Closed as not planned

Description

@nahoj

I use AI to review merge requests. The assistants I use all support git natively. However, they don't know how to check all changes since the parent branch, because the "parent branch" is not a standard git concept.

So every time I just give the AI the parent branch name or the command to get it.

It would be nice if the git MCP offered this function.

Here is the command I use; I think it is a reasonable definition of a parent branch:

Find the first commit on the current branch that is on a branch other than the current branch or any remote with the same name.
Print the name of any such branch.

current_branch=$(git rev-parse --abbrev-ref HEAD) && \
for commit in $(git rev-list HEAD); do \
  other_branch=$(git branch -a --contains $commit | \
                /usr/bin/grep -Ev -m 1 "^[ *]*(remotes/.*/)?$current_branch$" | \
                sed -r 's#^[ *]*(remotes/)?##' | \
                xargs); \
  [[ -n "$other_branch" ]] && echo "$other_branch" && break; \
done

Activity

  1. cliffhall commented on Oct 19, 2026

    @cliffhall
    Member

    Closing: out of scope for the reference servers.

    Thank you for the suggestion, and apologies for the long wait for a response.

    These servers are reference implementations: they exist to show how each part of MCP is used, not to be general-purpose products, so new features are taken selectively (CONTRIBUTING.md). A 'parent branch' is not a git concept and the proposed heuristic is opinionated; it is better served by git_diff against a named branch or an extended server. This is not a judgment on the idea or on you; a server in the MCP Registry may well offer it, and anyone is welcome to build on these servers to do so. This is happening as part of the backlog triage in #4875.

  2. added
    closed-out-of-scopeClosed: out of scope here; listings and new servers go to the MCP Registry (#4875)
    on Oct 19, 2026
  3. nahoj commented on Oct 19, 2026

    @nahoj
    Author

    Understood, no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed-out-of-scopeClosed: out of scope here; listings and new servers go to the MCP Registry (#4875)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions