【问题标题】:LibGit2SharpException v0.26.0.0 - git fetch exposes an exception 'too many redirects or authentication replays private repository'LibGit2SharpException v0.26.0.0 - git fetch 暴露异常“重定向或身份验证重放私有存储库太多”
【发布时间】:2020-04-11 03:49:30
【问题描述】:

我正在使用 LibGit2Sharp 库从我的私有存储库中获取代码,但我遇到了以下异常

LibGit2Sharp.LibGit2SharpException: 太多重定向或身份验证重放私有存储库

这是我的 git fetch 函数

public static void GitFetch()
    {
        string USERNAME = "myusername";
        string PASSWORD = "mypassword";

        string logMessage = "";
        using (var repo = new Repository(@"D:\GitHub\my-test-repo"))
        {
            FetchOptions options = new FetchOptions();
            options.CredentialsProvider = new CredentialsHandler((url, usernameFromUrl, types) =>
                new UsernamePasswordCredentials()
                {
                    Username = USERNAME,
                    Password = PASSWORD
                });

            foreach (Remote remote in repo.Network.Remotes)
            {
                IEnumerable<string> refSpecs = remote.FetchRefSpecs.Select(x => x.Specification);
                Commands.Fetch(repo, remote.Name, refSpecs, options, logMessage);
            }
        }
        Console.WriteLine(logMessage);
    }

异常暴露在一行

Commands.Fetch(repo, remote.Name, refSpecs, options, logMessage);

谁能告诉我我错了什么?对我有什么建议吗?

【问题讨论】:

    标签: c# .net github repository


    【解决方案1】:

    我遇到了类似的问题,尽管我使用的是 AccessKey 而不是密码。虽然我的令牌没有过期,但重新生成它可以解决问题。不确定更改密码是否会导致类似的修复。

    【讨论】:

    • 感谢您分享您的经验。我会试试看
    猜你喜欢
    • 1970-01-01
    • 2015-02-06
    • 2016-07-26
    • 2018-05-09
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 1970-01-01
    • 2012-05-01
    相关资源
    最近更新 更多