我正在寻找一个很好的清洁示例,说明如何使用lidgit2sharp进行拉动。我在这里做了一个获取fetch的例子,但对Credentials的引用抛出异常。
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"
}
});
}
例外是无法创建抽象类的实例或 界面' LibGit2Sharp.Credentials'
答案 0 :(得分:3)
它告诉你错误:Credentials是一个抽象类,接口,等等。
试试这个:
Credentials credentials = new UsernamePasswordCredentials()
{
Username = "username",
Password = "password"
}