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