Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't git-daemon serve my repository?

Tags:

git

git-daemon

I set up .git in a directory on my local machine. I then run:

mkdir a cd a git init git daemon

When I attempt to clone the repository in a, I get the following error:

mkdir b cd b git clone git://127.0.0.1 Initialized empty Git repository in /b/127.0.0.1/.git/ fatal: The remote end hung up unexpectedly

How can I clone my repository over the git protocol?

like image 783
yazz.com Avatar asked Mar 29 '10 13:03

yazz.com


People also ask

What is git daemon?

git-daemon is a simple server for git repositories. The daemon makes git repositories available over the git:// protocol, which is very efficient, but insecure.

Is there a git daemon?

Git daemon is run via git daemon (notice no hyphen). However, you should take a look at Gitolite or similar if you intend on hosting Git repositories on a server. Further, why are you cloning a repository with the intention of having that cloned, and any pushes to it forwarded to the repo it was cloned from?

Why git clone is not working?

If you have a problem cloning a repository, or using it once it has been created, check the following: Ensure that the user has gone through initial GitCentric login and has the correct username, email, and ssh. This should return a usage message that refers to the config-branch, config-repo, and ls-repo commands.


1 Answers

You need to let git-daemon know it may export your repository:

$ git init --bare /tmp/my-repo.git Initialized empty Git repository in /tmp/my-repo.git/  $ git daemon --verbose --base-path=/tmp --export-all /tmp/my-repo.git &  $ git clone git://`hostname`/my-repo.git Initialized empty Git repository in /tmp/my-repo/.git/ warning: You appear to have cloned an empty repository.

A far better way is to run it from xinetd. Create and tweak /etc/xinetd.d/git along the lines of

# description: The git server offers access to git repositories service git {         disable = no         type            = UNLISTED         port            = 9418         socket_type     = stream         wait            = no         user            = nobody         server          = /usr/local/bin/git         server_args     = daemon --inetd --export-all --base-path=/pub/scm         log_on_failure  += USERID } 

Don't forget to sudo killall -HUP xinetd. Now, all git repositories beneath /pub/scm will be available to anyone who asks.

like image 90
Greg Bacon Avatar answered Sep 22 '22 05:09

Greg Bacon