1
在混帐我可以运行命令:如何获得包含在libgit2sharp提交远程分支机构的名单
git branch -r --contains '#commit-hash#'
其中列出了必须提交我感兴趣的远程分支
我已阅读libgit2sharp wiki上的文档,但是有地方分支的例子吗?
如何在中做同样的事情libgit2sharp?
在混帐我可以运行命令:如何获得包含在libgit2sharp提交远程分支机构的名单
git branch -r --contains '#commit-hash#'
其中列出了必须提交我感兴趣的远程分支
我已阅读libgit2sharp wiki上的文档,但是有地方分支的例子吗?
如何在中做同样的事情libgit2sharp?
看libgit2wiki文件后,可以修改他们的示例代码看起来像这样:
using (var repo = new Repository("path/to/your/repo"))
{
const string commitSha = "5b5b025afb0b4c913b4c338a42934a3863bf3644";
foreach(Branch b in ListBranchesContainingCommit(repo, commitSha))
{
Console.WriteLine(b.Name);
}
}
private IEnumerable<Branch> ListBranchesContainingCommit(Repository repo, string commitSha)
{
var commit = repo.Lookup<Commit>(commitSha);var commit = repo.Lookup<Commit>(commitSha);
IEnumerable<Reference> headsContainingTheCommit = repo.Refs.ReachableFrom(repo.Refs, new[] {commit});
return headsContainingTheCommit.Select(branchRef => repo.Branches[branchRef.CanonicalName]).ToList();
}
太好了!这工作 - 感谢代码 –
不客气:-) – Slartibartfast