如何使用 libgit2sharp 获取后面/前面的提交数量?

fer*_*rit 5 git libgit2 libgit2sharp git-rev-list

可以使用git rev-list命令获取后面/前面的提交数量。我正在尝试使用libgit2sharp库来实现同样的事情,但是该库没有完整记录,所以我找不到如何实现。

我正在寻找一个使用 获取后面/前面提交号的示例libgit2sharp

Abd*_*oui 5

完成 Jason Haslam 给出的答案...这是一个如何获取HistoryDivergence每个分支前后提交数量的示例:

using (var repo = new Repository("/path/to/repo"))
{
     foreach (Branch b in repo.Branches)
     {
               // if branch does not have a remote b.TrackingDetails.AheadBy and b.TrackingDetails.BehindBy will be both null
               var commitsAhead = b.TrackingDetails.AheadBy;
               var commitsBehind = b.TrackingDetails.BehindBy;
               Console.WriteLine($"Branch {b.FriendlyName} is {commitsAhead} ahead and {commitsBehind} behind");
      }
}
Run Code Online (Sandbox Code Playgroud)