码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu Git服务器搭建

时间:2016-02-18 11:54:34      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

1.安装git和ssh工具

apt-get install git-core openssh-server openssh-client

2.添加用户名为git的用户

useradd -m git

passwd git

3.新建git仓库目录并且修改目录权限

mkdir /home/gitprojects

chown git:git /home/gitprojects

chmod 700 /home/gitprojects

4.安装gitosis

apt-get install python-setuptools

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

cd gitosis

python setup.py install

5.切换为git用户,链接/home/gitprojects和 /home/git/repositories 下

su git

ln -s /home/gitprojects /home/git/repositories 

6.配置gitosis

需要在客户端电脑上生成sshkey并且上传 id_rsa.pub 到服务器某个目录

ssh-keygen –t rsa

scp xxx/.ssh/id_rsa.pub root@10.203.148.102:/home/id_rsa.pub

7.在服务器上修改id_rsa.pub权限并运行gitosis

chmod a+r /tmp/id_rsa.pub

sudo –H –u git gitosis-init </home/id_rsa.pub

8.修改post-update文件权限

sudo chmod 755 /home/gitprojects/gitosis-admin.git/hooks/post-update

9.在服务器上新建仓库lsgame.git

su git 

cd /home/gitprojects

git init --bare lsgame.git

10.配置gitosis

回到客户端clone gitosis-admin.git

git clone git@10.203.148.102:gitosis-admin.git

gitosis中将其他主机的sshkey重命名后放入keydir里,并根据需要配置gitosis.conf文件

例子

[gitosis]

[group gitosis-admin]

members = ye@Binary

writable = gitosis-admin

 

[group lsgame]

members = ye@Binary

 

writable = lsgame

提交修改配置

git add .

git commit -am "xx"

git push origin master

11.客户端提交代码

git init

git add .

git commit -am "initial version"

git remote add origin git@<server>:lsgame.git

git push origin master

Ubuntu Git服务器搭建

标签:

原文地址:http://www.cnblogs.com/yao-blog/p/5197254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!