C# 如何使用LibGit2Sharp从Git获取更改?
下面的代码将Git url克隆到测试目录C# 如何使用LibGit2Sharp从Git获取更改?,c#,.net,git,version-control,libgit2sharp,C#,.net,Git,Version Control,Libgit2sharp,下面的代码将Git url克隆到测试目录 var url = @"http://abc-555.com/team/project-555.git"; var path = @"E:\temp_555"; var credential = new Credentials() { Username = "a8888", Password="88888888"}; var clonePath = Repository.Clone(url, path, credentials: credential
var url = @"http://abc-555.com/team/project-555.git";
var path = @"E:\temp_555";
var credential = new Credentials() { Username = "a8888", Password="88888888"};
var clonePath = Repository.Clone(url, path, credentials: credential);
using (var repo = new Repository(clonePath))
{
foreach (var branch in repo.Branches)
{
Console.WriteLine(branch.Name);
}
// somebody creates a new branch here, so I want to fetch it.
repo.Fetch("origin");
foreach (var branch in repo.Branches)
{
Console.WriteLine(branch.Name);
}
}
我想先获取一个新分支,然后再将其合并到本地Git。无论如何,它抛出了libgit2引发的一个错误。类别=净(错误)。请求失败,状态代码为:401异常
如何解决此问题?您可以指定通过实例使用的凭据作为
获取调用的最后一个参数
repo.Fetch("origin", new FetchOptions { Credentials = credential});
此API已过时,请使用