Pergunta

I have a git url like git@test-git-server:product/test-product.get which contains 2 branches. I want to get every branch associated with that url.

I tried getting information from location directory cloned from that url but it shows only main branch.

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?

Foi útil?

Solução

You need to look at the Branches property in Repository:

/// <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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top