Radu Cotescu's professional blog

g33k w17h pa45510n

Gitosis and Read-only Git Repositories

When I’ve started working with Git, besides using the quick how-to guides from the official site, I’ve also wanted to read a more detailed book about how this distributed VCS tool should be used in order to benefit from all of its functionalities. One of these books is Pro Git by Scott Chacon, from Apress. The e-book version I own dates from September 2009, although its content is freely available (with the proper updates and revisions) here.

One of the most interesting tools for Git is Gitosis, an application which allows you to automate repository management and to have your own hosted repo on one of your servers (click here to install it on Ubuntu; a good start-up guide can be found here). In my case, this server is Geordi. While I do use GitHub too, Gitosis manages my non-public projects. Not only that Gitosis creates your repositories on the server once you need them, but it also handles user access allowing to have multiple users (commiters or followers) with read/write rights depending on the project.

Today I wanted to allow Tudor to be able to clone one of my private repositories but in the same time I didn’t want to give him push permissions. The edition of Pro Git I have listed this configuration for the previous job:

[group groupName]
writable = repoName
members = user1 user 2 user3

[group groupName-readonly]
readable = repoName
members = user 4

With this set-up, every time when Tudor tried to clone my repository, Gitosis would respond with:

ERROR:gitosis.serve.main:Repository read access denied
fatal: The remote end hung up unexpectedly

The problem was on the highlighted line. It seems that the correct keyword for setting read-only user access is nothing other than readonly. With that put up in place everything worked as it should from the beginning. Although the online book now uses the correct keyword, you might still find PDF files of the book with the wrong example in which case you now have a solution.

Keep on pushing! ;)

Code, How To, Linux

« A few clarifications about VMware Server and the Linux kernels Oracle vs. Google and Java Patents »