0
votes

I am trying to clone a repository with the below C# code

try
{
  var result = Repository.Clone(remoteUrl, localPath);
}
catch (Exception ex)
{
}

Repository.Clone() does not return, and there is no thrown exception. Is there anything wrong with the code? Am I missing something?

1

1 Answers

1
votes

I know a lot of time has passed since this question was asked, but this is how I do it (in case it is still helpful):

Repository.Clone("https://repository.git", deployerPath, new CloneOptions()
{
    BranchName = "branch_to_pull_from",
    CredentialsProvider = CredentialsProvider(),
});

The CredentialsProvider method should return a Credentials object via the CredentialsHandler delegate, provided in the LibGit2Sharp.Handlers namespace.

By the way, I'm using LibGit2Sharp version 0.26.1, in which an exception is actually thrown in this scenario.