Gitolite 是一个新量级的Git服务,特别适合个人用户在网上建立自己的Git仓库。本文将描述如何建立Gitolite服务并设置 git-daemon 监听
前置必要条件:
-
Linux 系统(本文描述中使用的是CentOS 7)
-
git(可以使用系统自带的也可以自己编译,本文描述中所提到的git是自己编译的)
-
git-daemon(可以使用系统自带的也可以自己编译,本文描述中所提到的git-daemon是自己编译的)
-
open-ssh服务(CentOS已经默认安装、如果是Ubuntu则需要安装opensshd服务)
因为在我的服务器上端口9418已经被占用,所以在本文中将对git-daemon另外设置端口。
搭建过程:
# useradd git
# su git
$ cd ~
$ mkdir -p ~/.local/bin
$ cd .local
$ git clone https://github.com/sitaramc/gitolite.git
$ cd gitolite
$ ./install -to ~/.local/bin
$ cd ~
$ ssh-keygen
$ cp .ssh/id_rsa.pub git.pub
$ source ~/.bash_profile
$ gitolite setup -pk git.pub
$ exit
# vim /lib/systemd/system/git-daemon.service
[Unit]
Description=Start Git Daemon
[Service]
ExecStart=/usr/local/bin/git daemon --reuseaddr --base-path=/home/git/repositories --export-all --port=<你自定义的Port>
Restart=always
RestartSec=500ms
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=git-daemon
User=git
Group=git
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# service git-daemon start
# netstat -tnpla | grep <你自定义的Port>
安装完成。以下是测试: