调整
可以使用 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
函数