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. Python数据类型list(列表)和tuple(元组)

    list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. 比如,列出班里所有同学的名字,就可以用一个list表示: >>> ...

  2. Weblogic11g+Axis1.4 实现WebService服务

    IDE:NetBeans8.0 项目结构: (1)新建接口Hello.java package com.test; /** * @author y * @date 2015-9-5 7:51:29 * ...

  3. codeproject

    search: http http://www.codeproject.com/Articles/96620/Writing-Http-Handlers-and-Modules-in-IIS-7-5 ...

  4. 使用 Spring Boot 快速构建 Spring 框架应用,PropertyPlaceholderConfigurer

    Spring 框架对于很多 Java 开发人员来说都不陌生.自从 2002 年发布以来,Spring 框架已经成为企业应用开发领域非常流行的基础框架.有大量的企业应用基于 Spring 框架来开发.S ...

  5. 【HDOJ】1619 Unidirectional TSP

    题目本身一点儿都不难,但是就是被字典序搞死了.写的挺麻烦,但是过了,逆向做好做一点儿. /* 1619 */ #include <cstdio> #include <cstring& ...

  6. 【HDOJ】4884 TIANKENG's rice shop

    简单模拟,注意并不是完全按照FIFO的顺序.比如第i个人的id为k,那么就算第i+1人的id不为k,也会检查他后续的排队人是否有id为k的. #include <cstdio> #incl ...

  7. delphi 句柄

    句柄Handle顾名思义就是把柄,把手的意思 ,得到了某对象的句柄可以任意控制此对象 .句柄是一种指向指针的指针.不是每个组件都有句柄,只有窗口控件等(*.模块(module)*.任务(task)*. ...

  8. Delphi 使用自定义消息

    Delphi 使用自定义消息   1.先用Const 定义一个常量,例如 const WM_MyMessage=WM_USER+$200; 2.在要实现的unit中定义一个私有方法 procedure ...

  9. Best Time to Buy and Sell Stock——LeetCode

    Say you have an array for which the ith element is the price of a given stock on day i. If you were ...

  10. Java实现文件的预览

    最近项目需要用到文件的预览功能,就开始在网上收集资料,学习了几种文件预览的方法.我集成到我项目内测试的有以下三种,最后使用的是第三种: 直接使用别人提供的服务 例如:office web 365 使用 ...