2011-06-12 84 views
15

我在我的服务器上建立了一个git仓库。创建了一个新用户'git'。我的回购地址位于/srv/git/example.git。我能够git remote add origin [email protected]/srv/git/example.git然后我添加并承诺我的更改。如何解决执行git push时拒绝.git /目录的权限?

然而,当我试图git push origin master它失败了:

fatal: unable to create temporary file: permission denied' and 'fatal: sha1 file write error: invalid argument'

在我跑的服务器:

sudo chown -R git:git /srv/git/` 

这个固定我的问题,但我想如果这是应该做的正确的事吗?

回答

19

On the server I ran sudo chown -R git:git /srv/git/ - this fixed my problem but I am wondering if this was the correct thing to do?

绝对如此。之前的问题是,通过SSH登录的git用户无法写入存储库。

根据您的需要,您可能会考虑用户和SSH密钥的不同组合,或者可以用来更好地控制访问的许多其他程序(gitolite等)之一。

7

首先,修复远程.git目录中的文件权限,例如,

sudo chmod -R ug+w /var/www/.git 
sudo chown -R git:git /var/www/.git 

root:root,如果你想分配root组的成员推送权限。需要

在目标主机上然后git仓库作为共享要被设置,所以在远程需要下面的命令来运行:

git config core.sharedRepository group 
相关问题