Git-daemon - how does one update cloned repo>?

133 Views Asked by At

I need allow anon access to a few repos. I read a few how-tos and docs on git-daemon that use the git clone clone --bare approach and serve the cloned repo, with git-daemon. This works fine, installed it via aptitude and it runs merrily as a service in /etc/srv/git-daemon.

My question is, once devel has more commits, how do you update and sync the cloned instance being used as public repository?

Also, this repo is also writable it seems (obvious, but surely not always wanted), is it possible to make git-daemon serve read-only?

1

There are 1 best solutions below

0
On

For making a repository read-only for all, writable only for some users, the easiest way would be to add an authorization layer like gitolite.

You can plug it in to a gitweb, or just to an http(s) access, like I do in this Apache configuration, which can be setup for requiring an authentication.

So you can keep your current git-daemon, for read-only access, but you can add an (authenticated) https access for write purpose, allowing you to control precisely who can do what to which repos (through gitolite).

You will also be able to add a post-receive hook to your writable upstream repo, in order for that hook to cd to the other read-only repo, and do a git fetch.

#!/bin/bash
export GIT_DIR=/path/to/bare/read-only-repo.git/
cd $GIT_DIR
git fetch --all