2010-03-29 39 views
21

Ho impostato .git in una directory sul mio computer locale. Ho poi corro:Perché git-daemon non servirà il mio repository?

mkdir a 
cd a 
git init 
git daemon

Quando si tenta di clonare il repository in a, ottengo il seguente errore:

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

Come posso clonare il mio repository tramite il protocollo git?

risposta

39

È necessario lasciare git-daemon So che può esportare il 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.

Un modo di gran lunga migliore è di lanciarlo da xinetd. Creare e modificare /etc/xinetd.d/git lungo le linee di

# 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 
} 

Non dimenticate di sudo killall -HUP xinetd. Ora, tutti i repository git sotto /pub/scm saranno disponibili per chiunque lo chieda.

13

È necessario inserire un file vuoto denominato git-daemon-export-ok nel repository o avviare git daemon con l'opzione --export-all.

Citazione dal git-daemon man page:

It verifies that the directory has the magic file "git-daemon-export-ok", and it will refuse to export any git directory that hasn't explicitly been marked for export this way (unless the --export-all parameter is specified). If you pass some directory paths as git daemon arguments, you can further restrict the offers to a whitelist comprising of those.

+1

Solo l'aggiunta di questo: Nel mio caso "git-daemon-export-ok" non era leggibile da parte dell'utente git-ro che era in esecuzione il demone. – Belac

Problemi correlati