【centos6.5系统安装git服务器搭建】Centos6.5系统安装Git服务器Gitosis步骤

时间:2019-10-24  来源:CentOS  阅读:


1.服务器上安装Git

通过ssh登录服务器安装git

yum install git


安装时出现“No package git available. Nothing to do”问题

需要先添加EPEL(Extra Packages for Enterprise Linux) repository:

CentOS5.x 32-bit(x86/i386):  
  
 rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm  
  
CentOS5.x 64-bit(x64):  
  
 rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm  
  
 CentOS6.x32-bit (x86/i386):  
  
 rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm  
  
CentOS6.x 64-bit(x64):  
  
 rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm 
 
然后yum install git就能安装了。

根据centos的版本,安装对应的EPEL

cat /etc/redhat-release    查看系统版本

2.服务器上安装gitosis

sudo yum install python python-setuptools

cd /usr/local/src

git clone git://github.com/res0nat0r/gitosis.git

cd gitosis

python setup.py install

3.本机上生产密钥,并将公钥上传服务器

ssh-keygen -t rsa #一路回车,不需要设置密码

#上传公钥到服务器(默认SSH端口22)
scp ~/.ssh/id_rsa.pub root@服务器IP:/tmp

4.回到服务器,初始化gitosis

# 创建git版本管理用户 git
sudo adduser git
# 更改git

用户的密码

sudo passwd git
# su 到git用户
su ? git
gitosis-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/
#删除密钥
rm -rf /tmp/id_rsa.pub

5.本机上导出gitosis项目

mkdir -p /repo # p层级创建目录

cd /repo

git clone git@服务器IP:gitosis-admin.gi

6.添加团队其他成员

ls keydir 看到当前只有你自己的公钥文件
将第3步的过程让团队成员都生成一下,上传或拷贝到此目录

把协同开发者的id_rsa.pub 文件里的数据 拷贝到 对应的开发者的密钥用户名.pub文件。如把密钥用户名 guangyun.ni@yeepay.com 的 id_rsa.pub 文件中文本 粘贴到 guangyun.ni@yeepay.com.pub 文件里,并保存

vim gitosis.conf

[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = winstar@Josh.local #该组的成员(密钥用户名) 多个用户协同开发时,以空格分隔
[group renhetest]
writable = renhetest
members = winstar@Josh.local
renhetest是我新加的测试项目,writable配成git项目名
#提交修改
git add .
git commit -a -m “add test-git repo”
git push
 

初始化renhetest测试项目

cd ~/repo

mkdir renhetest

cd renhetest

git init

touch readme.txt

git add .

git commit -a -m “init test-git”

git remote add origin git@ServerIp:test-git.git

git push origin master


好了这样安装配置及项目配置 测试也就搞好了,各位朋友不防去试一下吧。

 

【centos6.5系统安装git服务器搭建】Centos6.5系统安装Git服务器Gitosis步骤

http://m.bbyears.com/caozuoxitong/75168.html

推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新