(本文需要自己实践,由于时间关系,我仅仅是做了整理和快速的练习,至于笔记中的账号和ip域名都是我参考文章中的。如果读者有任何问题欢迎留言和发邮件到luoquantao@126.com)

硬件:云端阿里云服务器

软件:云端:gitosis + git + ssh

   本地:cygwin 或者 gitbash

参考文章:http://www.open-open.com/lib/view/open1349849744275.html

     http://bdxnote.blog.163.com/blog/static/844423520124137333373/

     http://book.51cto.com/art/201107/278832.htm

       http://blog.csdn.net/ice520301/article/details/6142503

       http://blog.csdn.net/markddi/article/details/8289774

详细步骤如下:

1:创建git账号用于管理git服务器

  useradd -s /bin/bash -d /home/git -G root -m -c "Manager for git server" -p git git
     其中,-p:指定账户git的密码;
        -m:强制创建git账户的home目录;
        -d:指定git账号的home目录;
        -s:指定git账号的登录shell;
        -G:指定git账户所属的用户组;
        -c:指定git账号的描述;

  passwd git 设置git的密码:此处设置为git

  如果在后面使用sudo的时候报错,需要修改/etc/sudoers文件

2: 升级系统

  sudo apt-get update

  sudo apt-get upgrade

3: 安装git相关的组件(包括git、openssh)

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

4:安装gitosis

  4-1:初始化git服务器所管理的账户(提交代码时的账号)

    git@zxk:~$ git config --global user.name "zxk"
        git@zxk:~$ git config --global user.email "zxk@163.com"

  4-2:安装python的setup tool,为安装gitosis做准备

    git@zxk:~$ sudo apt-get install python-setuptools

  4-3:获取gitosis安装包

     git@zxk:~$ mkdir ~/.gitosis_setop
        git@zxk:~$ cd ~/.gitosis_setop/
         git@zxk:~/.gitosis_setop$ git clone git://eagain.net/gitosis.git
         如果这个不行:
         Cloning into 'gitosis'...
         fatal: unable to connect to eagain.net:
         eagain.net[0: 208.78.102.120]: errno=Connection refused
         则可从如下位置clone gitosis包:
         git clone https://github.com/res0nat0r/gitosis.git

  4-4:安装gitosis包

     git@zxk:~/.gitosis_setop$ cd gitosis/
        git@zxk:~/.gitosis_setop/gitosis$ sudo python setup.py install
         若报错,可通过如下命令解决:
         git@zxk:wget http://peak.telecommunity.com/dist/ez_setup.py
         git@zxk:python ez_setup.py

  4-5:生成ssh公钥,并上传到git服务器上,或直接使用git账户在git服务器上生成,现在采用git账户直接在git服务器上生成。

     git@zxk:~$ ssh-keygen -t rsa

4-6:初始化gitosis

     git@zxk:~$ sudo -H -u git gitosis-init < ~/.ssh/id_rsa
         Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
         Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/

     gitosis默认会把git仓库房子git账户的目录下:也就是/home/git下面

     gitosis的有趣之处在于,它通过一个git仓库管理配置文件

    仓库就放在/home/git/repositories/gitosis-admin.git, 我们需要对一个文件加个权限

     git@zxk:~$ pwd
         /home/git
         git@zxk:~$ chmod 755 repositories/gitosis-admin.git/hooks/post-update

  4-7:配置gitosis, 以控制git客户端的操作

   git@zxk:~$ git clone git@192.168.0.251:repositories/gitosis-admin.git

git@zxk:~$ cd gitosis-admin/
      git@zxk:~/gitosis-admin$ vi gitosis.conf 
      [gitosis]
      loglevel = DEBUG

[group gitosis-admin]                 #gitosis-admin为git组名;
      witeable = gitosis-admin              #gitosis-admin为仓库名;
      members = git@zxk root@zxk zxk@zxk

#下面两个group配置实现把仓库teamwork的只读权限分配给git组team;
      #同时,把仓库teamwork的可写权限分配给git组team_ro;
      [group team]                          #team为git组名;
      writable = teamwork                   #teamwork为仓库名;
      members = a@svr b

   

git@zxk:~/gitosis-admin$ git add -A
      git@zxk:~/gitosis-admin$ git commit -m "init gitosis-admin config gitosis.conf"
      [master 2691646] init gitosis-admin config gitosis.conf
      1 file changed, 4 insertions(+)

git@zxk:~/gitosis-admin$ git push origin master
      git@192.168.0.251's password: 
      Counting objects: 5, done.

  4-8:创建一个仓库的存储位置,并初始化

   git@zxk:~$ mkdir -p /repo/top1

      git@zxk:~$ cd /repo/top1/
      git@zxk:/repo/top1$ git init --bare

#在当前项目仓库中配置访问该仓库的用户信息:
      git@zxk:/repo/top1$ git config --add user.name "zxk"
      git@zxk:/repo/top1$ git config --add user.email "zxk@163.com"
      git@zxk:/repo/top1$ git config --add user.name "bliss"
      git@zxk:/repo/top1$ git config --add user.email "bliss@163.com"
      git@zxk:/repo/top1$ git config --add user.name "dummy"
      git@zxk:/repo/top1$ git config --add user.email "dummy@163.com"
      这些信息被添加在当前项目仓库的.git/config文件的[user]段中了;

如果git config命令加上--global选项,那些这些用户信息就会被添加到~/.gitconfig文件的[user]段中;
      如:
      git@zxk:/repo/top1$ git config --global --add user.name "zhangsan"
      git@zxk:/repo/top1$ git config --global  --add user.email "zhangsan@163.com"

如果git config命令加上--file选项,那些这些用户信息就会被添加到--file所指定的文件的[user]段中;

  4-9:在客户端直接clone该仓库就可以了;

   git clone zxk@192.168.0.251:/repo/top1 test
      然后初始化第一个版本的数据并提交;

基于gitosis的Git云端服务器配置的更多相关文章

  1. 在centos 下安装配置基于gitosis 的git 服务

    前言 这里我用的系统是centos 6.2, 在服务器上的准备工作(服务器IP为10.0.2.8 ): 1.安装 openssh服务器与客户端工具 $ sudo yum install openssh ...

  2. 使用Gitosis搭建Git服务器

    使用Gitosis搭建Git服务器 作者: JeremyWei | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明 网址: http://weizhifeng.net/build- ...

  3. centos git版本服务器配置

    在服务器上安装git及做些操作 - 执行命令 ` sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-de ...

  4. 基于 Jenkins+Docker+Git 的CI流程初探

    在如今的互联网时代,随着软件开发复杂度的不断提高,软件开发和发布管理也越来越重要.目前已经形成一套标准的流程,最重要的组成部分就是持续集成(Continuous Integration,CI)及持续部 ...

  5. Windows下基于http的git服务器搭建-gitstack

    版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:Windows下基于http的git服务器搭建-gitstack     本文地址:http: ...

  6. mac Git本地服务器配置

    本文转载至 http://blog.csdn.net/piziliweiguang/article/details/9311791   XCode 默认支持 Git 作为代码仓库,当我们新建一个仓库的 ...

  7. CentOS搭建GIT服务器【一】-仓库搭建以及基于gitosis的SSH方式访问

    1.安装GIT核心 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel gcc g ...

  8. Centos下使用gitosis配置管理git服务端(转载)

    From:http://www.cnblogs.com/ahauzyy/archive/2013/04/08/3043384.html 说明:由于条件有限,我这里使用的是同一台centos的,但教程内 ...

  9. # 基于Gitolite搭建Git Server - 支持SSH&HTTP

    Git, 一个分布式的版本管理工具,我认为其革命性的点:在于改变了用户协作的方式,使得协作更简单. 下面讲述 使用一个开源软件 Gitolite搭建一个Git Sever, 并给了一个推荐的团队协助方 ...

随机推荐

  1. subplot的应用

    import matplotlib.pyplot as Plot Plot.subplot(3, 4, (1, 7)) Plot.subplot(1, 4, 4) Plot.subplot(3, 4, ...

  2. CruiseControl.NET学习总结(转载)

    前些日子,总结了一个NAnt的学习总结.后来就放下了,松散了一阵子.CruiseControl.NET(以下称CC.NET),是我在学习完NAnt以后才开始看的,当时学起来就是在网上疯狂的找资料.现在 ...

  3. 实现ajax

    啊打发 <script type="text/javascript" src="js/jquery-1.8.3.min.js"></scrip ...

  4. jquery autocomplete 简单实用例子

    <link href="../../themes/default/css/jquery.ui.all.css" rel="stylesheet" type ...

  5. unity3d 日志捕捉

    public class Test : MonoBehaviour { public string output = ""; public string stack = " ...

  6. PHP静态延迟绑定

    静态延迟绑定的概念 PHP版本5.3起增加了静态延迟绑定,也称迟绑定,主要用于在继承范围内引用静态调用的类.简单地来说:static::不再被解析为当前方法所定义的类,而是在实际运行时计算的. // ...

  7. 2015安徽省赛 D.锐雯上单不给就送

    题目描述 <英雄联盟>(简称LOL)是由美国Riot Games开发,腾讯游戏运营的英雄对战网游.<英雄联盟>除了即时战略.团队作战外,还拥有特色的英雄.自动匹配的战网平台,包 ...

  8. http://www.zhihu.com/question/24896283

    http://www.zhihu.com/question/24896283 Rix Tox,太不專業了 三百.知乎用户.raintorr 等人赞同 1. 更改变量名的几种方法这种情况下该如何快速选中 ...

  9. sass的视频教程

    http://www.w3ci.com/video/715.html http://koala-app.com/index-zh.html /***************三角形的应用******** ...

  10. css排版

    先介绍如何设定字体.颜色.大小.段落空白等比较简单的应用,后面再介绍下比如首字下沉.首行缩进.最后讲一些常用的web页面中文排版,比如中文字的截断.固定宽度词内折行(word-wrap和word-br ...