Why won't git-daemon serve my repository?

前端 未结 2 1411
暗喜
暗喜 2020-12-25 12:25

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

2条回答
  •  难免孤独
    2020-12-25 12:40

    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.

提交回复
热议问题