libgit2sharp 0.21.0.176 C# on Windows Server 2008
I need to obtain reference to a specific branch.
On my Windows machine, I fresh git clone local repo from remote origin on GitHub.
Next I execute following libgit2sharp
code :
var localRepo = new Repository({local-path},RepositoryOptions);
var remote = localRepo.Network.Remotes.Add("origin", {remote-repo-uri);
localRepo.Network.Fetch(remote, FetchOptions, Signature, "performing fetch");
var branch = localRepo.Branches[{branch-name}];
But the branch is not present in the collection even though it exists on remote origin on GitHub.
Similarly to git, only the default branch (or the one that has been specified in CloneOptions.BranchName
) is created as a local head upon cloning.
Other branches are fetched, but only as remote tracking branches.
Two options:
localRepo.Branches["origin/{branch-name}"];