为什么git-daemon不会服务我的仓库? [英] Why won't git-daemon serve my repository?

查看:107
本文介绍了为什么git-daemon不会服务我的仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地机器的目录中设置了 .git 。然后我运行:

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

mkdir a
cd a
git init
git daemon

当我尝试克隆 a 中的存储库时,出现以下错误:

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

如何通过git协议克隆我的存储库?

How can I clone my repository over the git protocol?

推荐答案

您需要让 git-daemon 知道它可能导出您的存储库:

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.

更好的方法是从运行它xinetd的。按照

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
}

不要忘记 sudo killall -HUP xinetd 。现在,任何询问的人都可以使用 / pub / scm 下的所有git存储库。

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

这篇关于为什么git-daemon不会服务我的仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆