首页 > 系统服务 > 详细

Linux的centos搭建git服务器

时间:2015-04-16 01:06:45      阅读:262      评论:0      收藏:0      [点我收藏+]

1.安装git用yum install git-core(服务器)

2.创建裸仓库(服务器)

[root@localhost]$ mkdir /home/workspace
[root@localhost]$ cd /home/workspace
[root@localhost]$ git init -bare wwwroot.git

 

3.给权限(服务器)

chown -R git:git wwwroot.git

4.添加git用户和密码(服务器)

adduser git

passwd git 123

5.禁止shell登陆如果不知道git在哪里用:which git-shell 查找出来填写正确路径(服务器)

编辑/etc/passwd

git:x:1001:1001:,,,:/home/git:/bin/bash

改为:

git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

6.用clone远程下载git项目(客户端)

git clone git@115.28.38.789:/home/workspacewwwroot.git

IP和路径一定要填写正确

7.客户端可以操作git相关操作了

git add *

git commit -m ‘add‘

git remote add origin git@115.28.38.789:/home/workspacewwwroot.git   (只在第一次关联的时候使用,第二次不需要在使用,直接push就可以了

git push origin master

项目每次修改或添加就可以这些命令完成

8.进行git和web目录关联,同步浏览网站

设置钩子,这样每次运行git就可以同步提交浏览网站了

[root@localhost]$ cd /home/workspace/wwwroot.git/hooks
[root@localhost]$ cat > post-receive <<EOF
>#!/bin/bash
>git --work-tree=/home/website/wwwroot checkout -f 
>EOF
[root@localhost]$ chmod +x post-receive

分布式服务器,每一个电脑都可以作为git服务器,每个电脑都是一个节点!祝君好运!

Linux的centos搭建git服务器

原文:http://www.cnblogs.com/feimengv/p/4430541.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!