David Jack Wange Olrik

Tea. Earl Grey. Hot.

Wildcard Repositories With Gitolite

A while ago I upgraded from Gitosis to Gitolite. I’ve been using Gitosis for a long time and while there is nothing wrong with Gitosis, Gitolite just does so much more.

One of my favorite features is wildcard repositories which makes it super easy to have normal users create as many repositories as they can imaging without having to bother a git-admin.

To setup a sandbox for each user you must first enable wildcard repositories in ~/.gitolite.rc. You do this by setting $GL_WILDREPOS to 1.

After that you just need to configure the userspace like this1:

repo user/CREATOR/[a-zA-Z0-9_\.\-]+
C = @admins CREATOR
RW+ = @admins

Note the use of CREATOR, this is a variable signifying the user that creates and accesses the repository. The CREATOR can even delegate permissions2 to other users if needed.

To get your locally created repository up on the new upstream, you first add the new remote and then you just push it up. For convenience you can also make you local repository track the new upstream using git branch --set-upstream-to3 which will save you a lot of key strokes4 in the long run.

git remote add origin git@git.domain.com:user/<$USER>/<$REPO>.git
git push origin master
git branch --set-upstream-to=origin/master master

That’s it! - Hope you enjoy wildcard repositories as much as I do.

  1. Feel free to select your preferred permissions for the repositories.

  2. You do this by using setperms on the remote repository.

  3. Note you’ll need at least git version 1.8.0 for git branch --set-upstream-to.

  4. When you track a branch you don’t have to provide the full refspec each time you push or pull.