gitolite建立git服务器

1. gitolite 安装


 1.1 环境


      * any unix system
      * sh
      * git 1.6.6+
      * perl 5.8.8+
      * openssh 5.0+
      * a dedicated userid to host the repos (in this document, we assume it
        is 'git'), with shell access ONLY by 'su - git' from some other userid
        on the same server.


1.2   创建git 用户


        sudo adduser --system --shell /bin/bash --group git

        sudo passwd git  


1.3  管理员权限的ssh key


       客户机运行ssh-keygen

      将生成的公钥拷贝到服务器git根目录


1.4 安装


     确保bin目录,.gitolite目录,.ssh/authorized_keys,projects.list ,repositories不存在

   git clone git://github.com/sitaramc/gitolite

       mkdir -p ~/bin

     ./gitolite/install -to ~/bin

      ./bin/gitolite setup -pk xxxx.pub     #xxx.pub为gitolite管理员


1.5 修改安装目录


     setup之前修改~/.gitolite.rc如下:分别修改repositories,.gitolite,及log的路径

%RC = (

    # ------------------------------------------------------------------

    # default umask gives you perms of '0700'; see the rc file docs for
    # how/why you might change this
    UMASK                           =>  0077,

    # look for "git-config" in the documentation
    GIT_CONFIG_KEYS                 =>  '',

    # comment out if you don't need all the extra detail in the logfile
    LOG_EXTRA                       =>  1,

    GL_REPO_BASE                    => "/home/lucid/project/work/codehouse/repositories",
    GL_ADMIN_BASE                   => "/home/lucid/project/work/codehouse/.gitolite",
    LOG_TEMPLATE                    => "/home/lucid/project/work/codehouse/.gitolite/logs/gitolite-%y-%m.log",


    # roles.  add more roles (like MANAGER, TESTER, ...) here.
    #   WARNING: if you make changes to this hash, you MUST run 'gitolite
    #   compile' afterward, and possibly also 'gitolite trigger POST_COMPILE'
    ROLES => {
        READERS                     =>  1,
        WRITERS                     =>  1,
    },


1.6 检出


   git clone [email protected]:gitolite-admin.git

    当出现Agent admitted failure to sign using the key错误时,

    应用 ssh-add 指令將私钥加进来

    ssh-add   ~/.ssh/id_rsa

2. 本地库迁移至gitolite


2.1 配置gitolite 版本库


          检出的gitolite-admin.git中存在conf/gitolite.conf如下:

repo gitolite-admin
    RW+     =   id_rsa

repo testing                  ###########版本库
    RW+     =   @all       ########权限


 2.2 本地库提交到gitolite


       git remote add origin [email protected]

      如果出错fatal: remote origin already exists.

       执行git remote rm origin

       git push origin master






你可能感兴趣的:(gitolite建立git服务器)