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

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


当前回答

修复权限

我用这个来修复我的。git文件夹,@richard-hansen的答案缺少用户。

首先,您需要进入.git文件夹。

cd /path/to/repo/.git

然后执行这些命令。

sudo chown -R user:groupname .
sudo chmod -R g+rwX .
sudo find . -type d -exec chmod g+s '{}' +

这也将修复所有子模块。

其他回答

适用于Ubuntu(或任何Linux)

从项目根,

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

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

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

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

您需要对要推入的目录具有足够的写权限。

在我的例子中:Windows 2008服务器

右键单击git回购目录或父目录。

属性>共享选项卡>高级共享>权限>确保用户具有适当的访问权限。

我将补充我的意见,作为一种发现目录中具有特定所有权的文件的方法。

该问题是由于以根用户身份运行某些git命令引起的。 收到的信息是:

$ git commit -a -m "fix xxx"
error: insufficient permission for adding an object to repository database .git/objects
error: setup.sh: failed to insert into database

我首先查看了git config -l,然后我解决了:

find .git/ -exec stat --format="%G %n" {} + |grep root

chown -R $(id -un):$(id -gn) .git/objects/

git commit -a -m "fixed git objects ownership"

sudo chmod -R ug+w .;

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

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

/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中)