Git: Cloning gitosis admin repo locally

£可爱£侵袭症+ 提交于 2020-01-15 14:24:18

问题


I set up a git repo with gitosis on my ubuntu 10.04 server using the following guide: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

It works fine and dandy, I can clone the configuration to my ubuntu 10.10 desktop computer, and commit changes there.

Thats Ok, but I do most of my actual coding on the server. So I will need to clone the configuration/gitosis-admin.git repo and the other repos locally.

git clone --local file:///home/git/repositories/gitosis-admin.git gives me: fatal: '/home/git/repositories/gitosis-admin.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly

I added my server user to group git and got: fatal: failed to open '/home/git/repositories/gitosis-admin.git/objects': Permission denied

I then tried to make a public key on the server, and adding it to the keys admin repo, added the username, both as (user) and (user)@(hostname) in the configuration, to: git clone git@localhost:gitosis-admin.git or git clone git@(hostname):gitosis-admin.git both of which asks me for git@(hostname) password

When I go back to my desktop, and check out the gitosis-admin repo, the gitosis.conf lists: [gitosis]
[group gitosis-admin]
writable gitosis-admin
members = (desktopUN)@(desktopHostname) (serverUN)@(serverHostname)

but on the server, if I root into /home/git/repositories/gitosis-admin.git/ and cat gitosis.conf, it lists [gitosis]
[group gitosis-admin]
writable gitosis-admin
members = (desktopUN)@(desktopHostname)

I can't get my head around this, how do I set this up to get it working the way I want to. The chances are great that there is some noob coughup on my part behind all this, but I've spent 5 hours trying to get this to work now, and it takes me 2 min to set up a svn repo. So I'm getting impatient ..

Thanks


回答1:


You need to either add the ssh public key of the user on server to gitosis or copy the ssh private key from the desktop to the user on the server and use it.

Sorry I kinda skimmed the question at first. How did you install gitosis? I remember there being a common issue where during the install, a required hook in the gitosis-admin repo was not set to be executable. As a result it never updated the config when pushed to.

Also you should only ever access repos hosted with gitosis through SSH and not through the local filesystem, but you seem to have figured this part out already.

Additionally if you are not aware, gitosis is unmaintained and deprecated in favor of gitolite.




回答2:


I want to give a detailed answer to this question because I just had to use a gitosis-admin local clone to get somebody else's installation working properly. I think other users might come here looking for help figuring out what to do if you need to edit gitosis-admin but ONLY have local root access to the filesystem on which the repos live. If that's how you got here, your intuition is good in that you can clone and edit the gitosis-admin repository locally. To make everything work, though, you have to be careful about how you do it. Here are the steps:

Preconditions:

  • You are root.
  • You want to give $USER gitosis-admin access; $USER is a valid user.
  • The gitosis-admin repository lives at $PATH. (On Ubuntu this is typically /srv/gitosis/repositories/gitosis-admin.git)
  • $PATH is owned by user "gitosis".

Steps:

  1. If they don't already have one, generate a key pair for the user you want to give gitosis-admin access to.
    sudo -H -u $USER ssh-keygen
  2. Make a local clone of the gitosis-admin repo as the gitosis user.
    sudo -H -u gitosis git clone $PATH
  3. Add the new public key.
    sudo -H -u gitosis cp ~$USER/.ssh/id_rsa.pub ./gitosis-admin/keydir/$USER.pub
  4. Edit the gitosis-admin conf as necessary.
    sudo -H -u gitosis nano ./gitosis-admin/gitosis.conf
  5. Commit as the gitosis user.
    sudo -H -u gitosis git commit -am "Adding $USER" ./gitosis-admin
  6. Push as the gitosis user.
    sudo -H -u gitosis git push ./gitosis-admin
  7. Run the post-update hooks as the gitosis user.
    sudo -H -u gitosis GIT_DIR=$PATH $PATH/hooks/post-update


来源:https://stackoverflow.com/questions/4979170/git-cloning-gitosis-admin-repo-locally

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