1
votes

I want to use labgit2sharp to replace the command -- "git pull“ to pull my code from my gitlab. but it is not successful by using the following code:

using (var repo = new Repository(remotePath))
{
    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", emailaddress, new DateTimeOffset(DateTime.Now)), options)
}

Could you help me? I want to know all the steps from the beginning. Thanks very much!

1
What are you using for remotePath? This has to be a local file path, not your remote Git source. Also post the error/stack trace that you are getting. - SushiHangover
ok,thanks!but there has a error:Type initializer exception - 崔重阳
how can i solve it? or i lack some steps? - 崔重阳
Post your exception stack trace in your question - SushiHangover
- $exception {"“LibGit2Sharp.Core.NativeMethods”的类型初始值设定项引发异常。"} System.TypeInitializationException - InnerException {"无法加载 DLL“git2-785d8c4”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。"} System.Exception {System.DllNotFoundException} - 崔重阳

1 Answers

1
votes

Network.Pull is no more used. Please try using LibGit2Sharp.Commands.Pull()