Question

I'm looking for a nice clean example of how to do a pull using lidgit2sharp. I took the example here which does a fetch, but the reference to Credentials is throwing an exception.

using (var repo = new Repository(workingDir, null))
{
    Remote remote = repo.Network.Remotes.Add("master", repoUrl);
    repo.Network.Fetch(remote, 
    {    
        Credentials credentials = new Credentials
        {
            Username = "username",
            Password = "password"
        }
    });
}

The exception is Cannot create an instance of the abstract class or interface 'LibGit2Sharp.Credentials'

Was it helpful?

Solution

It's telling you in the error: Credentials is an abstract class, interface, whatever.

Try this:

Credentials credentials = new UsernamePasswordCredentials()
{

        Username = "username",
        Password = "password"
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top