This very short tutorial assumes that you have already installed gitolite. Gitolite itself does not provide public read access; it always requires an SSH key. That’s where git-daemon
is needed, it will allow to git clone git://example.org/myRepository.git
.
Running the daemon
To run git-daemon as daemon on startup, install the git-daemon-run
package. The daemon can then be started/stopped with:
The file /etc/sv/git-daemon/run
then needs to be adjusted as described here:
- The git daemon has to be run as user which is also in the group
gitolite
to allow read access on gitolite’s repositories - The path to the gitolite repository has to be corrected
File permissions
Cloning will not work yet since the gitolite repositories are set to rwx------
. As described in the gitolite documentation[1] the permissions for newly created files can be set in the .gitolite.rc file which is in gitolite’s home path, in this case at /var/lib/gitolite/.gitolite.rc
.
As only new files will set to rwxr-x---
now, the existing repositories which should be shared need to be updated.
Enabling sharing in gitolite
git-daemon only shares a repository if the file git-daemon-export-ok
is available in its root directory. You could create it using touch path/to/repo.git/git-daemon-export-ok
, but a more elegant way is to do this via the gitolite-admin repository[2] by giving the special user daemon
read access. After pushing the changes to the server, gitolite will create the git-daemon-export-ok
for you.
That’s it!
Debugging
For the error messages check the error log on the server at /var/log/git-daemon/
, the most recent file is called current
. The error message that is seen most frequently:
foo.git does not appear to be a git repository
This is usually a permission problem and can be fixed by following this tutorial closely. Especially check the following points:
- Are the file permissions for the repository to share correct?
- Is the user and group under which the daemon is being run correct? For this example: Is gituser in the gitolite group?
It may also be a path problem. For example, on debian the base-path seems to be set to /var/cache
by default, where you usually do not have any git repository.
Connection refused
Client error message (no error message on the server):
This error message is shown when the connection fails. (Obviously.) Either because git-daemon is not running (check with ps -e |grep git-daemon
on the server), or because it has been restarted without using the --reuseaddr
flag.
The first can be solved by starting the daemon (sv start git-daemon
), the second by adding the --reuseaddr
flag and stopping and then starting the daemon again. You may have to wait for a minute or so first due to timeouts (see the daemon’s manpage).
Links
- ^ .gitolite.rc documentation
- ^ gitolite-admin.git documentation