之前用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
$ 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 就没有问题了