New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git merge-base command into GitPython #169

jwir3 opened this Issue Jun 30, 2014 · 6 comments


None yet
5 participants

jwir3 commented Jun 30, 2014

It would be nice if there was a way in the GitPython API to do the following native git command:

git merge-base <commit 1> <commit 2>

For example, it would be nice to be able to perform the following:

from git import *

repo = Repo('/path/to/repo')
base = repo.find_last_common_ancestor('de1f33', '78dd34')

The expected output, assuming the least common ancestor of 'de1f33' and '78dd34' was '6ff871', (obviously all of these commits have fictional SHAs) would be:

<git.Commit "6ff871652e0f3b9fa991bbd9b42e520f91723436e">

@Byron Byron added this to the v0.3.6 - Features milestone Nov 19, 2014


This comment has been minimized.

ereOn commented Jan 8, 2015

Note that the merge-base command does not take only two commits but any number of commits so the implemented solution should offer that possibility as well.

@Byron Byron self-assigned this Jan 13, 2015

@Byron Byron added the acknowledged label Jan 13, 2015

@Byron Byron closed this in e973e6f Jan 13, 2015


This comment has been minimized.


Byron commented Jan 13, 2015

Repo.merge_base() was implemented, including a rather straightforward test-case.
All the requested are supported, after all, I am just calling the cgit implementation and interpret its return values.


This comment has been minimized.


Byron commented Jan 13, 2015

You can watch the development video on youtube


This comment has been minimized.

sonicfly commented Feb 4, 2015

This implementation doesn't support "--is-ancestor" flag very well, it returns empty list for both 0 and 1 status code case.


This comment has been minimized.


Byron commented Feb 5, 2015

Can you please open a new issue with some information about the version of GitPython and python you are using, along with how I can reproduce the issue ?
Thanks a lot !


This comment has been minimized.

lahirug commented Dec 2, 2015

Does this support getting the common ancestor commit of two given branches ?
ex: git merge-base origin/release/1.30 origin/release/1.31

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