我为此苦苦挣扎。我正在尝试使用以下代码将更改推送到存储库:
// 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的用户权限有关。
关于git - Gig2go : unpacking the sent packfile failed on the remote,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31707337/