Skip to content

unpacking the sent packfile failed on the remote #1162

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

Open
sudeeptarlekar opened this issue May 7, 2025 · 0 comments
Open

unpacking the sent packfile failed on the remote #1162

sudeeptarlekar opened this issue May 7, 2025 · 0 comments

Comments

@sudeeptarlekar
Copy link

Getting error while pushing a new branch using library

unpacking the sent packfile failed on the remote; class=Net (12)

but if I go to directory and try to push the branch using Git with command, it works without any issues.

git push <remote> refs/remotes/<remote>/<branch>:refs/heads/<branch>

So I am not able to figure out if I am doing anything wrong in script that I wrote or if there is some issue on server.

Here is sample script

    let ssh_key =
        std::path::PathBuf::from(<SSH private key path>)
    let repo = git2::Repository::open(".")?;
    let mut remote = repo.find_remote(<remote_name>)?;

    let mut push_options = git2::PushOptions::new();
    let mut cbs = git2::RemoteCallbacks::new();
    cbs.credentials(|_url, username, _allowed_type| {
        git2::Cred::ssh_key(username.unwrap(), None, &ssh_key, None)
    });
    push_options.remote_callbacks(cbs);

    remote.push(
        &[&format!(
            "refs/remotes/upstream/<branch>:refs/heads/<branch>",
        )],
        Some(&mut push_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