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

push the code is not working on windows #938

Open
phostann opened this issue Mar 13, 2023 · 2 comments
Open

push the code is not working on windows #938

phostann opened this issue Mar 13, 2023 · 2 comments

Comments

@phostann
Copy link

here is my code

pub fn push(&self, branch: &str) -> Result<()> {
        let mut remote = self
            .repo
            .find_remote("origin")
            .with_context(|| "Failed to push the repository")?;

        let branch = self
            .repo
            .find_branch(branch, git2::BranchType::Local)
            .with_context(|| "Failed to find the branch")?;

        let refs = branch.into_reference();

        let name = refs.name().with_context(|| "The reference name is none")?;

        let mut callbacks = git2::RemoteCallbacks::new();
        callbacks.credentials(|_url, username_from_url, _allowed_types| {
            tracing::info!("Allowed types: {:?}", _allowed_types);

            Cred::ssh_key(
                username_from_url.unwrap(),
                None,
                std::path::Path::new(self.pub_key.as_str()),
                None,
            )
        });

        let mut options = git2::PushOptions::new();

        options.remote_callbacks(callbacks);

        // push the code to master branch
        remote
            .push(&[name], Some(&mut options))
            .with_context(|| "Failed to push the code")?;

        Ok(())
    }

it's working fine on mac but get an error on windows failed to set hostkey preference: The requested method(s) are not currently supported; class=Ssh (23)

@renat33112
Copy link

Hi @phostann! Have the same issue on windows 11. Did you fix it somehow?
Everything working at linux (ubuntu 22.04), but getting the same error on windows 11

@Olaroll
Copy link

Olaroll commented Nov 29, 2023

I also have this error when attempting to clone a repository. Any help or pointers would be much appreciated.

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

3 participants