1、服务器环境

lsb_release –a

LSB Version:	:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:	CentOS
Description:	CentOS release 6.8 (Final)
Release:	6.8
Codename:	Final

2、安装依赖

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel –y

3、Git安装</>

1.  wget https://www.kernel.org/pub/software/scm/git/git-2.5.0.tar.gz
2.  tar zxvf git-2.5.0.tar.gz
3.  cd git-2.5.0
4.  ./configure --prefix=/usr/local/git
5.  make && make install
6.  ln -s /usr/local/git/bin/* /usr/bin/
7.  git --version #显示版本号,安装成功
8.  git version 2.5.0

4、权限管理安装

权限管理工具gitosis的安装,需要用到python-setuptools

1.  yum install python python-setuptools
2.  git clone git://github.com/res0nat0r/gitosis.git
3.  cd gitosis/
4.  python setup.py install
5.  ……
6.  Using /usr/lib/python2.6/site-packages
7.  Finished processing dependencies for gitosis==0.2 #安装成功

5、管理公钥

管理Git服务器需要一个管理员,通过上传开发者机器公钥到服务器,添加成管理员。

$ssh-keygen -t rsa #一路回车,不需要设置密码
$scp ~/.ssh/id_rsa.pub root@10.10.105.15:~

6、Gitosis初始化

服务器上生成git用户,使用git用户并初始化gitosis,创建git版本管理用户git

useradd -c "git version manager" -m -d /home/git -s /bin/bash git
passwd git

初始化

mv id_rsa.pub /home/git/
su git
gitosis-init < ./id_rsa.pub
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git
chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update #加权限
posted on 2016-10-14 10:52  yanweiqi  阅读(267)  评论(0编辑  收藏  举报