Gig2go:在远程解压发送的包文件失败

Gig2go: unpacking the sent packfile failed on the remote

我为此苦苦挣扎。我正在尝试使用以下代码将更改推送到存储库:

// Get remote
remote, err := repo.Remotes.Lookup("origin")
if err != nil {
    remote, err = repo.Remotes.Create("origin", repo.Path())
    if err != nil {
        return err
    }
}

// Get the branch
branch, err := repo.Branch()
if err != nil {
    return err
}

// Get the name
branchName, err := branch.Name()
if err != nil {
    return err
}

if err := remote.Push([]string{"refs/heads/"+branchName}, &git.PushOptions{}); err != nil {
    return err
}

一切似乎都很好,但我不断收到此错误:

unpacking the sent packfile failed on the remote

阅读一些 git 资源后,我现在明白了错误的含义,但我仍然不知道是什么原因造成的。


编辑

我刚刚按照@Carlos 的建议尝试使用 Git,现在我正在获取更多信息:

git push --set-upstream origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 241 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To http://xxxxxxx/xxxxxx/app.git
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'http://xxxxxxx/xxxxxxx/app.git'

我以为我获得了正确的权限,这是我的 Git 目录在服务器上的样子:

root@CodeSpaces-001:/home/git# ll
total 40
drwxr-xr-x 5 git  git  4096 Jul 29 19:22 ./
drwxr-xr-x 3 root root 4096 Jul 29 18:21 ../
drwxrwxr-x 3 git  git  4096 Jul 29 19:22 apps/ # My repos are in here

这还不够吗?

这是一个错误,发生在服务器上,所以要查看它的日志。您是否尝试过对 git 本身进行相同的操作?我不记得了,但可能有一个额外的错误字符串,libgit2 目前没有返回。

在服务器上解压的错误通常与远程用户 git 是 运行 的用户权限有关。

我在 VSTS 同步期间遇到了同样的问题,并且在 VSTS 输出 window 中看到了相同的错误消息。

我的解决方法是转到 https://app.vssps.visualstudio.com/_signedin,然后很可能让我的信用登录到远程服务器。

之后,再次回到VSTS和Sync,错误消失了。嗨。