如何解决执行git push时拒绝.git /目录的权限? [英] How to fix permission denied for .git/ directory when performing git push?

查看:1310
本文介绍了如何解决执行git push时拒绝.git /目录的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的服务器上建立了一个git存储库。创建了一个新用户'git'。我的回购站位于 /srv/git/example.git 中。我能够 git remote add origin git@domain/srv/git/example.git 然后我添加并提交了我的更改。



然而,当我尝试 git push origin master 时,它失败:


fatal:无法创建临时文件:permission denied'and'fatal:sha1 file write error:invalid argument'


我运行的服务器:

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

这解决了我的问题,但我想知道这是否是正确的做法?


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



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


I have set up a git repository on my server. Created a new user 'git'. My repos are located in /srv/git/example.git. I was able to git remote add origin git@domain/srv/git/example.git then I added and committed my changes.

However when I tried git push origin master it failed on:

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

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?

解决方案

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?

Absolutely. The problem previously was that the git user, who you're logging in as via SSH, could not write to the repository.

Depending on your needs, you may consider different combinations of users and SSH keys, or one of the many additional programs (gitolite etc) that can be used to more finely control access.

这篇关于如何解决执行git push时拒绝.git /目录的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆