如何通过libgit2sharp在/领先的后面获得提交数量



可以使用 git rev-list命令获得/提前的提交数量。我正在尝试使用libgit2sharp库来实现同一件事,但库未完全记录,因此我找不到。

我正在寻找一个用libgit2sharp的在/提前提交数字的示例。

完成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");
      }
}

查看HistoryDivergence类。它从libgit2。

调整git_graph_ahead_behind函数

最新更新