Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Hdurian-CH opened this issue Aug 8, 2024 · 0 comments

Comments

@Hdurian-CH
Copy link

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant