当我尝试推到共享git远程时,我得到以下错误: 向存储库数据库添加对象权限不足

这适用于下一次推送,因为所有的文件都属于正确的组,但下一次有人推送一个更改时,它会在对象文件夹中创建一个新项目,该项目的默认组为组。我唯一能想到的就是改变所有开发人员签入项目的默认组,但这似乎是一种hack。什么好主意吗?谢谢。


当前回答

我遇到了同样的问题。阅读这里,我意识到这是文件权限的消息是指。对我来说,解决办法是:

/etc/inetd.d/git-gpv

它以“nobody”用户启动git-daemon,因此缺乏写权限。

# Who   When    What
# GPV   20Nov13 Created this by hand while reading: http://linuxclues.blogspot.co.uk/2013/06>/git-daemon-ssh-create-repository-debian.html
# GPV   20Nov13 Changed owner (to user_git) otherise nobody lack permission to update the repository
#git stream tcp nowait nobody  /usr/bin/git git daemon --inetd --verbose --enable=receive-pack --export-all /gitrepo
git stream tcp nowait user_git  /usr/bin/git git daemon --inetd --verbose --enable=receive-pack --export-all /gitrepo

(我怀疑其他人把他们的inetd conf文件称为git-gpv。通常它会直接在/etc/inetd.conf中)

其他回答

为我解决了… 就在这个:

sudo chmod 777 -R .git/objects

我在使用Vagrant运行远程开发开发机器时得到了这个错误。上述解决方案都不能工作,因为所有文件都具有正确的权限。

我把config.vm.box = "hasicorp/ bioniic64 "改为config.vm.box = "bento/ubuntu-20.10"。

适用于Ubuntu(或任何Linux)

从项目根,

cd .git/objects
ls -al
sudo chown -R yourname:yourgroup *

你可以通过以下方式说出你的名字和你所在的小组:

# for yourname
whoami
# for yourgroup
id -g -n <yourname>

注意:记住sudo行末尾的星号

在我的例子中,解决方案就是git再次提交。

问题自动解决了。

发生了什么事?我使用^C (Control-C)来避免写错误的提交消息。(我从错误的剪贴板中粘贴了错误的消息。)因此,我假设进程暂时冻结在后台,这暂时锁定了数据库。

sudo chmod -R ug+w .;

基本上,.git/objects文件没有写权限。上面的代码行授予目录中所有文件和文件夹的权限。