-
Notifications
You must be signed in to change notification settings - Fork 895
git merge base
vpfau edited this page Oct 24, 2018
·
1 revision
$ git merge-base oneCommit secondCommit
public string GetMergeBase(string a, string b)
{
using (var repo = new Repository("path/to/your/repo"))
{
var aCommit = repo.Lookup<Commit>(a);
var bCommit = repo.Lookup<Commit>(b);
if (aCommit == null || bCommit == null)
return null;
var baseCommit = repo.ObjectDatabase.FindMergeBase(aCommit, bCommit);
return baseCommit != null ? baseCommit.Sha : null;
}
}