[英]How to get branches using LibGit2Sharp?
I have a git url like git@test-git-server:product/test-product.get
which contains 2 branches. 我有一个git网址,如
git@test-git-server:product/test-product.get
,其中包含2个分支。 I want to get every branch associated with that url. 我想获取与该URL相关的每个分支。
I tried getting information from location directory cloned from that url but it shows only main branch. 我尝试从该URL克隆的位置目录中获取信息,但它仅显示主分支。
var repo = new Repository(path);
var remotes = repo.Network.Remotes;
foreach (var remote in remotes)
{
Debug.WriteLine("remote: {0}", remote.Name);
}
How to do this using LibGit2Sharp? 如何使用LibGit2Sharp做到这一点?
You need to look at the Branches
property in Repository
: 您需要查看
Repository
中的Branches
属性:
/// <summary>
/// Lookup and enumerate branches in the repository.
/// </summary>
public BranchCollection Branches
Source: Line 283 in here: https://github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp/Repository.cs 来源:此处的283行: https : //github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp/Repository.cs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.