Search code examples
gitgitolitegitlab

Configuring GitLab to store repositories for each user in personal directory


Just installed GitLab, it works perfectly with one exception: It stores repositories for all users in one directory by default, and if two users independently would try to create project with the same name, for example, "test", the second user will receive failure like "path already been taken".

The basic approach to isolate repositories of each user is to have them inside subfolders with username, just like GitHub does. But I have no idea how to do that.

I know GitLab uses Gitolite to manage repositories, and the last one have a feature that should allow it: it is named "wildcard users", in gitolite.conf it looks like this:

@wildcard_users = user1 user2 user3
repo    CREATOR/.*
    C     = @wildcard_users
    CRW+D = CREATOR
    RW    = WRITERS
    R     = READERS

This way we see CREATOR in repo path, which will be replaced with user name created repository. But the only way I see I could use this feature is to manually admin gitolite using a clone of gitolite-admin.git repository, and that kills the whole idea of GitLab where all things like this should be allowed through web interface.


Solution

  • The exact Gitolite feature covering that need is called "wild repos", and it is based on the user creating the repo (so, not GitLab)

    just create a new repo, as user "u4" (a student):

    $ git clone git@server:assignments/u4/a12
    Initialized empty Git repository in /home/sitaram/a12/.git/
    Initialized empty Git repository in /home/git/repositories/assignments/u4/a12.git/
    warning: You appear to have cloned an empty repository.
    

    Notice the two empty repo inits, and the order in which they occur ;-)

    GitLab doesn't support that workflow, and would need some large patch in order to manage repos which aren't directly under the repositories directory.