首页 > 代码库 > CentOS安装Git服务器 Centos 6.5 + Git 1.7.1.0 + gitosis

CentOS安装Git服务器 Centos 6.5 + Git 1.7.1.0 + gitosis

1.安装扩展

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

2、下载git

wget http://codemonkey.org.uk/projects/git-snapshots/git/git-2014-08-24.tar.xz 

3、解压安装

xz -d git-2014-08-24.tar.xz  tar xvf git-2014-08-24.tar
cd git
-2014-08-24make prefix=/usr/local/git allmake prefix=/usr/local/git install#增加软连接ln -s /usr/local/git/bin/* /usr/bin/git --version#如何能显示版本号,即表示成功

3.安装gitosis

yum install python python-setuptoolscd /usr/local/srcgit clone git://github.com/res0nat0r/gitosis.gitcd gitosispython setup.py install#显示Finished processing dependencies for gitosis==0.2即表示成功

4.在开发机上,生产密钥并上传到服务器上

ssh-keygen -t rsa#一路回车,不需要设置密码#上传公钥到服务器(默认SSH端口22)#scp ~/.ssh/id_rsa.pub root@192.168.1.225:/tmp或#scp ~/.ssh/id_rsa.pub root@www.domain.com:/tmp/#如修改SSH端口(端口8200)#git clone ssh://git@192.168.1.225:8200/gitosis-admin.git或#git clone ssh://git@www.domain.com:8200/gitosis-admin.git#修改配置文件,可以省略每次输入端口vim ~/.ssh/config#修改客户端~/.ssh/config文件,添加以下代码host www.domain.comhostname www.domain.comport 8200#修改后,客户端即可用以下方式进行连接#git clone ssh://git@www.domain.com/gitosis-admin.git#上传公钥到服务器(修改端口,并在配置中指定端口)scp ~/.ssh/id_rsa.pub root@www.domain.com:/tmp/ls /tmp/id_rsa.pub#显示已经上传的密钥

5.服务器上生成git用户,使用git用户并初始化gitosis

adduser -m gitsu - gitgitosis-init < /tmp/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/#删除密钥su - rootrm -rf /tmp/id_rsa.pub

6.在开发机上导出管理

mkdir -p /repocd /repogit clone git@www.domain.com:gitosis-admin.git

7.增加及设置管理项目

cd /repo/gitosis-admin#查看已经上传密钥ls keydircat keydir/vicowong\@VICO.pub  #vicowong@VICO.pub为已经上传的开发机生成的公密#显示密钥最后的符串为密钥用户名 这里为vicowong@VICOvim gitosis.conf#在文件尾增加以下内容[group test-git] # 组名称writable = test-git # 项目名称members = vicowong@VICO #密钥用户名#提交修改git add .git commit -a -m "add test-git repo"git push

8.初始,增加及使用项目test-git

cd /repomkdir test-gitcd test-gitgit intitouch readmegit add .git commit -a -m "init test-git"git remote add origin git@www.domain.com:test-git.gitgit push origin master

 

CentOS安装Git服务器 Centos 6.5 + Git 1.7.1.0 + gitosis