libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

LibGit2Sharp.LibGit2SharpException:“too many redirects or authentication replays”

Open Hdurian-CH opened this issue 1 year ago • 0 comments

I get LibGit2Sharp.LibGit2SharpException:“too many redirects or authentication replays” when I push the repository. I use username&&password in CredentialsProvider

using var repo = new Repository(rootPath);
var options = new PushOptions
{
    CredentialsProvider = (url, user, cred) =>
        new UsernamePasswordCredentials { Username = userName, Password = password },
};

var remoteName = "origin";
var remote = repo.Network.Remotes.FirstOrDefault(r => r.Name == remoteName);
 if (remote == null)
{
     repo.Network.Remotes.Add(remoteName, res);
}

 var branch = repo.Branches["main"];
if (branch == null)
 {
     branch = repo.CreateBranch("main");
 }
repo.Branches.Update(branch, b => b.Remote = remoteName, b => b.UpstreamBranch = branch.CanonicalName);
repo.Network.Push(branch, options);

Hdurian-CH avatar Aug 08 '24 02:08 Hdurian-CH