如何使用LibGit2Sharp获取分支?

时间:2014-02-24 07:28:05

标签: c# .net git version-control libgit2sharp

我有一个像git@test-git-server:product/test-product.get这样的git网址,其中包含2个分支。我想让每个分支都与该网址相关联。

我尝试从该网址克隆的位置目录中获取信息,但它只显示主分支。

var repo = new Repository(path);

var remotes = repo.Network.Remotes;

foreach (var remote in remotes)
{
    Debug.WriteLine("remote: {0}", remote.Name);
}

如何使用LibGit2Sharp执行此操作?

1 个答案:

答案 0 :(得分:2)

您需要查看Branches中的Repository媒体资源:

/// <summary>
/// Lookup and enumerate branches in the repository.
/// </summary>
public BranchCollection Branches

来源:第283行:https://github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp/Repository.cs