转自:http://blog.youkuaiyun.com/dengsilinming/article/details/7490335
1.安装git
先检查git 是否已经安装
- [root@localhost ~]# rpm -q git
- [root@localhost ~]# yum install git
安装完成后测试是否安装成功
- [root@localhost ~]# git --version
git version 1.7.1
2.设置git服务器
创建git服务器管理用户
- [dengsilinming@localhost ~]$sudo useradd -m git
- [dengsilinming@localhost ~]$sudo passwd git
创建git仓库存储目录
- [dengsilinming@localhost ~]$ sudo mkdir /home/git/repositories
- [dengsilinming@localhost ~]$ sudo chown git:git /home/git/repositories
- [dengsilinming@localhost ~]$ sudo chmod 755 /home/git/repositories
- [root@localhost ~]# git config --global user.name "linming"
- [root@localhost ~]# git config --global user.email linming@126.com
- [root@localhost ~]# yum install python-setuptools
- [dengsilinming@localhost gitosis]$ git clone git://eagain.net/gitosis.git
- eagain.net[0: 208.78.102.120]: errno=Connection refused
- fatal: unable to connect a socket (Connection refused)
- [dengsilinming@localhost tmp]$ git clone https://github.com/res0nat0r/gitosis.git
- [dengsilinming@localhost tmp]$ cd gitosis
- [dengsilinming@localhost gitosis]$ sudo python setup.py install
- [dengsilinming@localhost gitosis]$ ssh-keygen -t rsa#一直回车就行
- [dengsilinming@localhost gitosis]$ scp ~/.ssh/id_rsa.pub /tmp/ && chmod a+r /tmp/
- [dengsilinming@localhost gitosis]$ su git
- [dengsilinming@localhost gitosis]$ sudo -H -u git gitosis-init < /tmp/id_rsa.pub
- [root@localhost ~]# chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update