CentOs上搭建git服务器

首先安装setuptools

  1. wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
  2. tar zxvf setuptools-0.6c11.tar.gz
  3. cd setuptools-0.6c11
  4. python setup.py build
  5. python setup.py install

在服务器(CentOs)上首先安装git软件

  • yum insatll git

安装gitosis

  1. git clone git://github.com/res0nat0r/gitosis.git
  2. cd gitosis
  3. python setup.py install

添加用户git

sudo useradd -r -s /bin/sh -c 'git version control' -d /home/git git

设置权限

mkdir -p /home/git

chown git:git /home/git

ssh登陆验证

  • cat kailuzhe_rsa.pub >> authorized_keys authorized_keys存在,追加
  • mv kailuzhe_rsa.pub authorized_key authorized_keys不存在,改名

生成公钥

  • ssh-keygen -t rsa

上传公钥

  • scp ~/.ssh/id_rsa.pub USER@YOUR_SERVER:/tmp

在服务端生成管理库

  • sudo -H -u git gitosis-init < /tmp/id_rsa.pub

看到如下提示说明安装成功

Initialized empty Git repository in /var/spool/gitosis/repositories/gitosis-admin.git/ Reinitialized existing Git repository in /var/spool/gitosis/repositories/gitosis-admin.git/

修改上传权限

  • chmod 755 /var/spool/gitosis/repositories/gitosis-admin.git/hooks/post-update

同步配置文件

  • git clone git+ssh://git@118.123.16.30:22000/gitosis-admin.git

创建新的repositories

打开gitosis.conf文件,你将看到

[group gitosis-admin]

writable = gitosis-admin

members = nasa127@localhost

这个是管理组的权限,members中的用户名就是刚才上传的公钥里面的用户名。 在这个文件后面加入:

[group myteam]

members = nasa127@localhost

writable = diablo3_spider

这里你定义了一个叫myteam的组,授予nasa127@localhost这个用户写“diablo3_spider”这个repo的权限

git commit -a -m "Allow nasa write access to diablo3_spider"

git push

上面的操作就更新了服务端的权限。 下面就开始创建diablo3_spider的repo

mkdir diablo3_spider

cd diablo3_spider

git init

随便加一些文件提交代码:

git remote add origin git@YOUR_SERVER_HOSTNAME:diablo3_spider.git

git add .

git commit -a -m "initial import"

git push origin master:refs/heads/master

接下来,可以增加成员的公钥到系统中了

cd gitosis-admin

cp ~/Administrator@SUNPX-PC.pub keydir/

cp ~/tongzhongqian@localhost.pub keydir/

git add keydir/Administrator@SUNPX-PC.pub keydir/tongzhongqian@localhost.pub

修改gitosis.conf

[group fractalist]

members = nasa127@localhost Administrator@SUNPX-PC tongzhongqian@localhost

writable = GTFund-iPad

提交修改:

git commit -a -m "Granted sunpx and qtz commit rights to diablo3_spider"

git push

其它成员就可以获取代码了

git clone git@YOUR_SERVER:diablo3_spider.git

其他

对Git设置端口号

git+ssh://git@YOUR_SERVER:PORT/GTFund-iPad.git

git remote add origin git+ssh://git@YOUR_SERVER:PORT/GTFund-iPad.git

参考文档

  • http://blog.prosight.me/index.php/2009/07/271
  • http://blog.chinaunix.net/uid-26337130-id-3027600.html
  • https://github.com/res0nat0r/gitosis#using-gitweb
  • http://www.jiangmiao.org/blog/1600.html
  • http://hi.baidu.com/unspace/blog/item/81cef0d33db0f3c0a9ec9ab0.html
  • http://code.google.com/p/tortoisegit/

来自:http://www.cnblogs.com/nasa/archive/2012/05/31/2528901.html

自己添加的链接:

http://git-scm.com/book/zh/ch4-7.html

http://blog.csdn.net/king_sundi/article/details/7065525

CentOs上搭建git服务器的更多相关文章

  1. 在centos上搭建Git服务器

    第一步:先安装一些相关依赖库和编译工具 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel yum in ...

  2. Ubuntu上搭建Git服务器

    下面我们就看看,如何在Ubuntu上搭建Git服务器.我们使用VMware虚拟机安装两台Ubantu系统,分别命名为gitServer和gitClient_01. 1.安装OpenSSH并配置SSH无 ...

  3. centos上搭建git服务--3

    前言:当我们想要实现几个小伙伴合作开发同一个项目,或者建立一个资源分享平台的时候,GIT就是一个很好的选择.当然,既然是一个共有平台,那么把这个平台放到个人计算机上明显是不合适的,因此就要在服务器上搭 ...

  4. 如何在服务器上搭建git服务器

    参考文章: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770 ...

  5. centos上搭建git服务--2

    在 Linux 下搭建 Git 服务器   环境: 服务器 CentOS6.6 + git(version 1.7.1)客户端 Windows10 + git(version 2.8.4.window ...

  6. centos上搭建git服务--4

    Git是目前世界上最先进的分布式版本控制系统(没有之一).使用Svn的请参考<版本控制-svn服务器搭建和常用命令(centos 6.3)>,下面介绍Git的常用命令 常用命令 简单版 升 ...

  7. 【CentOS】搭建git服务器

    参考资料: https://github.com/jackliu2013/recipes/blob/master/doc/linux/CentOS_6.4_git服务器搭建.md http://blo ...

  8. Centos上搭建git服务

    1.安装Git $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel $ yum ...

  9. Centos 7 搭建git服务器及使用gitolite控制权限

    一.安装git yum install git git --version #查看git版本 二.升级git(可选,如果之前已经安装git,需要升级git到最新版本) git clone https: ...

随机推荐

  1. 网易DBA私享会分享会笔记2

    mysql索引与查询优化什么是索引?索引其实是一个目录.通过各种数据结构实现,是(值=>行位置)的映射 索引的作用:1.提高访问速度2.实现主键.唯一键逻辑 索引使用场景数据量特别大的时候,进行 ...

  2. SQL语句宝典

    1.前述: 将数据灵活运用于手掌心! link:1.经典SQL语句大全(cnblogs) 2.SQL教程(W3C)

  3. MVC中的UrlHelper

    authour: chenboyi updatetime: 2015-04-27 22:32:47 friendly link:   1,CodeSimple: ps:因为UrlHelper涉及的知识 ...

  4. python的sorted相关

    Python 字典排序 在python里,字典是内置的数据类型,是个无序的存储结构,每一个元素是key-value对: 有关key的解释: sorted(L,key=by_name)中的key即by_ ...

  5. 转:玩转Google开源C++单元测试框架Google Test系列

    转自http://www.cnblogs.com/coderzh/archive/2009/04/06/1426755.html 前段时间学习和了解了下Google的开源C++单元测试框架Google ...

  6. C语言学习笔记--类型定义&联合

    一.类型定义 C语言自定义数据类型 (typedef) C语言提供一个叫做typedef的功能来声明一个已有的数据类型的新名字. typedef int Length; 使得Length成为int类型 ...

  7. Color the ball

    hdu1556:http://acm.hdu.edu.cn/showproblem.php?pid=1556 题意:中文题. 题解:这一题当然可以直接用线段树来打,但是最近在学树状数组,所以用树状数组 ...

  8. 【HDOJ】2510 符号三角形

    暴力打表. #include <cstdio> ]={,,,,,,,,,,,,,,,,,,,,,,,,}; int main() { while (scanf("%d" ...

  9. 最近点对问题 HDU Quoit Design 1007 分治法

    #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #i ...

  10. bzoj2730 [HNOI2012]矿场搭建 (UVAlive5135 Mining Your Own Business)

    2730: [HNOI2012]矿场搭建 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1147  Solved: 528[Submit][Statu ...