最近买了个国外的VPS 用作FQ之余还准备搭个git仓库。在这里记录搭建的过程。
安装GIT
添加webtatic yum库,上面有最新版的git包
$ sudo rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
安装git:
$ sudo yum install --enablerepo=webtatic git
SSH密钥
检查~/.ssh目录下是否有id_rsa和id_rsa.pub文件
$ ls ~/.ssh id_rsa id_rsa.pub
有则跳过,没有则生成新的:
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/jarod/.ssh/id_rsa): Created directory '/home/jarod/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/jarod/.ssh/id_rsa. Your public key has been saved in /home/jarod/.ssh/id_rsa.pub. The key fingerprint is: 90:4a:49:4b:2d:35:0d:66:aa:5e:d7:b8:d5:39:45:ea jarod@vps
把id_rsa.pub上传到服务器
$ scp ~/.ssh/id_rsa.pub root@server_ip:/tmp/jarod.pub
安装gitolite
$ git clone git://github.com/sitaramc/gitolite $ cd gitolite $ sudo ./src/gl-system-install $ sudo useradd git # 添加git用户 $ sudo su git # 用git用户进行安装 $ gl-setup /tmp/jarod.pub
安装完成后默认会有两个git库
gitolite-admin - gitolite所有管理工作都只需要对这个库进行操作,包括库管理,用户管理,权限管理
testing - 测试练手用的库
把gitolite-admin clone到自己本机上
$ git clone git@server_ip:gitolite-admin
在本机修改gitolite-admin的配置,commit并push到服务器上即可生效