Skip to content

unpacking the sent packfile failed on the remote #1162

Open
@sudeeptarlekar

Description

@sudeeptarlekar

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),
    )?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions