【发布时间】:2021-12-14 09:28:38
【问题描述】:
我在尝试使用 libgit2sharp 从我的存储库中获取数据时遇到问题。
我正在尝试从我的 Github 存储库中获取。它是通过 https 克隆的。一旦 fetch 命令运行,LibGit2SharpException 就会抛出:"too many redirects or authentication replays".
我已经在这里阅读了其他一些问题,但到目前为止,它们都没有帮助。使用DefaultCredentials 只会导致 401 错误,这是有道理的。
有人知道如何解决这个问题吗?
using Repository repo = new Repository(@"path\to\repo");
Remote remote = repo.Network.Remotes["origin"];
IEnumerable<string> refSpec = remote.FetchRefSpecs.Select(x => x.Specification);
Credentials credentials = new UsernamePasswordCredentials { Username = "USER", Password = "PASS" };
Credentials Handler(string url, string fromUrl, SupportedCredentialTypes types) => credentials;
FetchOptions options = new FetchOptions { CredentialsProvider = Handler };
string log = "Fetching remote";
Commands.Fetch(repo, remote.Name, refSpec, options, log);
编辑:据我所知,问题是,它是一个私人仓库,因为我可以从 github 获取公共仓库。关于如何解决它的任何想法?
【问题讨论】:
标签: c# libgit2sharp