Administrating a git repo without root permissions

耗尽温柔 提交于 2019-12-11 12:22:20

问题


I want to make a bare git-repo in my home directory accessible to my co-workers working on the same file system, allowing them to git push into it. However, I don't want them to be able to accidentally modify the repo with anything but git, so I can't just chmod g+w it.

Is this possible without being root? The only thing I could think of was setting the SUID bit to git so git could access the repo as me, but I don't know if that is really such a good idea...


回答1:


You can use something like gitolite which deals with a lot of the hassle for you.

If you want to use plain git, you can do this:

To do this all of your co-workers and you need to be in the same group (e.g. developers). You can fix everything at once with:

newgrp developers
git init --bare --shared=group repo

but ofcourse you will get an empty repository. You can push your current work in there and continue from there.

If you do not use the git init path you will need to set the apprioprate permissions yourself as well as set the core.sharedrepository=1 config variable.




回答2:


If you're exposing your repo as a file:///, then file permissions will apply. As far as I know, git itself doesn't deal with "permissions". The mechanism you use to publish your repo takes care of that aspect (keys for ssh, .htacess or something for web).


This is untested but I think you should be able to setup a daemon using git daemon that your users can use to to push/pull from your repo. It will require read/write access to your repository but that's okay since it's running as you. Your users will be able to access your repo only using this. For details, check out the man page (git help daemon) and this. My original point, however, still stands. This is one way of not using the file:/// protocol to expose your repository that doesn't require root privileges.




回答3:


The best way is to use gitosis, or perhaps just something as simple as creating a new git user, and letting trusted users ssh into that account with ssh keys.

The latter doesn't really prevent people from accessing the files without using git, if that's important, spend the time to configure gitosis properly.



来源:https://stackoverflow.com/questions/4284650/administrating-a-git-repo-without-root-permissions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!