Libgit2sharp:how 使用“git 拉”

Libgit2sharp:how to use "git pull“

using (var repo = new Repository("path/to/your/repo"))
{
    LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions();
    options.FetchOptions = new FetchOptions();
    options.FetchOptions.CredentialsProvider = new CredentialsHandler(
        (url, usernameFromUrl, types) =>
            new UsernamePasswordCredentials()
            {
                Username = USERNAME,
                Password = PASSWORD
            });
    repo.Network.Pull(new LibGit2Sharp.Signature(USERNAME, EMAIL, new DateTimeOffset(DateTime.Now)), options)
}

我不知道怎么设置参数,用的时候会报错-----不支持URL protocol.could你告诉我怎么设置参数?

这取决于您使用的url。

例如,issue 649明确指出:

git.git supports relative URLs in remote configurations and resolves them relative to the working directory.
libgit2 currently fails with "Unsupported URL protocol".

It expects paths to be absolute.

因此,如果您的 url 实际上是本地路径,请确保它是绝对路径(而不是相对路径)。

作为 by 崔重阳,支持使用 https 而不是 sssh url。