These forums are read-only!
Shared git repository
  • I posted a question on StackOverflow without a good answer. Maybe someone here can help.

    I have an existing bare git repository located in /home/myaccount/git/project. I am currently using it over ssh from my local machine without any problems. I want to add a second user on the server which only shall access to this git repository (maybe move the repo outside my account folder?). How? Using latest version of git and ubuntu on slicehost.

    I have this setup: user: sleepyhead user: developer1 group: git. both sleepyhead and developer1 are members of this group repository /home/sleepyhead/git/project1

    I want to: move repository to a proper place, either /home/git/project1 or /usr/local/git/project1. What is recommended? developer1 should permissions to read and write project1 with git. no other permissions should be given.

    I do not know how to properly set the permissions and to restrict developer1 to only have access using git to project1.
  • You may want to have a look at gitosis, specifically this is a pretty decent tutorial for getting it setup:

    http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

    It's fairly easy to get up and running and allows for access to repos by multiple users.
  • If the second user is simply going to access the repository (and not write to it) you could always just serve it over HTTP or HTTPS and use basic authentication to protect it. That way you don't need to worry about users and permissions and what-not.

    Just create a bare repository on your slice and set some permissions for the web server:

    mkdir example-repo.git
    cd !$
    git --bare init --shared=group
    git --bare update-server-info
    sudo chown -R exampleuser:www-data example-repo.git
    sudo chmod -R ug+r example-repo.git
    

    And in Apache, protect the repository with something like:

    <Location /example-repo.git>
        AuthType Basic
        AuthName "Example Repository"
        AuthUserFile /home/example/.htpasswd
        Require valid-user
    </Location>