0

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

And how shows the download status using winforms progressbar, please? ty!
You can use 2 Progress Handlers, LibGit2Sharp.Handlers.TransferProgressHandler and LibBit2Sharp.Handlers.CheckoutProgressHandler and add them to your CloneOptions as OnCheckoutProgress and OnTransferProgress. I still can't get the Credentials part to work tho.
Is it possible to set configuration? i.e. core.longpaths = true?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.