`

git daemon

 
阅读更多
使用git协议架设git服务器,其中遇到许多问题,下面把过程记录下来。

1。事先你的git应装完了
#apt-get install git git-core
或用原码装

2。装git-daemon
#apt-get install git-daemon-run

3。设置/etc/service/git-daemon/run
bash$ cat /etc/service/git-daemon/run
#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
exec git daemon --reuseaddr --export-all --verbose --base-path=/wrgit /wrgit
bash$

注意:如果设置--export-all 可以不在相应的git 库中touc上生成一个git-daemon-export-ok,否则需要显示的生成这个空文件。

4. 重启git-daemon
bash$ ps -eaf | grep -v grep | grep git
root 5132 5086 0 08:44 ? 00:00:00 runsv git-daemon
gitlog 5195 5132 0 08:44 ? 00:00:00 svlogd -tt /var/log/git-daemon
root 16555 5132 0 16:57 ? 00:00:00 git-daemon --reuseaddr --export-all --verbose --base-path=/wrgit /wrgit

可以kill 掉对应进程,这时runsv会重启git-daemon
或使用
# sv down git-daemon
# sv up git-daemon

5. 查看 git-daemon所使用的端口是否工作正常
bash$ sudo lsof -i:9418
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
git-daemo 16555 root 3u IPv6 72970 TCP *:git (LISTEN)
git-daemo 16555 root 4u IPv4 72971 TCP *:git (LISTEN)

这一般下来应该没问题。
试试服务是否正常工作:
bash$ git clone git://128.224.159.140/demoCode
Initialized empty Git repository in /home/hyang0/aaaa/demoCode/.git/
remote: Counting objects: 54, done.
remote: Compressing objects: 100% (52/52), done.
remote: Total 54 (delta 2), reused 0 (deremote: lta 0)
Receiving objects: 100% (54/54), 80.17 KiB, done.
Resolving deltas: 100% (2/2), done.

我的/wrgit下的目录结构:
bash$ tree /wrgit -L 2
/wrgit
`-- demoCode.git
|-- HEAD
|-- branches
|-- config
|-- description
|-- git-daemon-export-ok
|-- hooks
|-- info
|-- objects
`-- refs

6 directories, 4 files
bash$
bash$ cat /wrgit/demoCode.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[daemon]
uploadpack = true
uploadarch = true
receivepack = true
bash$

如果还不能正常工作,可以看看你的 repository 配置是否正确,可以加个git-daemon-export-ok文件,或改改config 文件把receivepack = true打开。

具体参数可以参看 man git-daemon, 这里就不赘述。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics