9

每次我制作“git push origin master”时,我都有 git 错误:“将对象添加到存储库数据库的权限不足”。
我尝试了这里描述的解决方案:http: //parizek.com/2011/05/git-insufficient-permission-for-adding-an-object-to-repository-database-objects/但它只在下次之前有效......
有什么永久的解决办法吗?

$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.19 KiB, done.
Total 3 (delta 2), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To ssh://user@git.code.sf.net/p/project/code
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh://user@git.code.sf.net/p/project/code'

$ git config core.sharedRepository true

$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.19 KiB, done.
Total 3 (delta 2), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To ssh://user@git.code.sf.net/p/project/code
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh://user@git.code.sf.net/p/project/code'

$ sudo chmod -R g+ws *
$ sudo chgrp -R andrey *
$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.19 KiB, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: <Repository /git/p/project/code.git> refresh queued.
To ssh://user@git.code.sf.net/p/project/code
   acd82d2..f401c90  master -> master

这是我使用的 Ubuntu:12.04.1,和 git:1.7.9.5

4

2 回答 2

4

如“推送到 GitHub 时出错 - 将对象添加到存储库数据库的权限不足”中所述,除了 git config 设置之外,您还需要:

  • 首先umask为您的所有回购设置:(umask 002所以在您的服务器端)
  • 然后将 git 组设置rw为您的解决方案中提到的,仍然在服务器端。
于 2012-10-07T19:10:11.160 回答
1

这通常发生在有人在嘘根时承诺使用 git。在该过程中创建的 .git/* 文件受到保护,不会受到外部更改的影响。

chmod -R 777 .git 

是一个快速修复。

于 2017-10-25T17:34:41.470 回答