解决git clone失败的问题

之前用gitweb搭建了git服务器,在使用 git clone的时候遇到了问题:

$ git clone git://localhost/linux-3.10.28
Cloning into 'linux-3.10.28'...
fatal: unable to connect to localhost:
localhost[0: 127.0.0.1]: errno=Connection refused
经过排查,发现没有安装 git-daemon, 所以接下来安装 git-daemon:

$ sudo aptitude install git-daemon-run

然后,重新 clone:

$ git clone git://localhost/linux-3.10.28
Cloning into 'linux-3.10.28'...
fatal: remote error: access denied or repository not exported: /linux-3.10.28

还是有问题。

要解决这个问题,还要修改配置文件 /etc/sv/git-daemon/run

exec 2>&1
echo 'git-daemon starting.'
exec chpst -ugitdaemon \
  "$(git --exec-path)"/git-daemon --verbose --reuseaddr \
    --base-path=/var/lib /var/lib/git
修改以后的内容为:

#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
#exec chpst -ugitdaemon \
# "$(git --exec-path)"/git-daemon --verbose\
#  --base-path=/var/lib /var/lib/git
#exec chpst -ugitdaemon
  "$(git --exec-path)"/git-daemon --verbose\
    --export-all  --base-path=$HOME/repo --enable=receive-pack
下面解释一下几个参数的意义:

  --export-all
           Allow pulling from all directories that look like Git repositories
           (have the objects and refs subdirectories), even if they do not
           have the git-daemon-export-ok file.
       receive-pack
           This serves git send-pack clients, allowing anonymous push. It is
           disabled by default, as there is no authentication in the protocol
           (in other words, anybody can push anything into the repository,
           including removal of refs). This is solely meant for a closed LAN
           setting where everybody is friendly. This service can be enabled by
           setting daemon.receivepack configuration item to true.

然后, 重启 git deamon:

sudo sv stop git-daemon
sudo sv start git-daemon
或者:

sudo sv restart git-daemon

这样,再clone 就没有问题了



  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值