zoukankan      html  css  js  c++  java
  • 使用gitolite搭建Git服务器

    使用gitolite搭建Git服务器

    运行环境

    • Ubuntu18.04

    • gitolite

    搭建过程

    1. 安装好Ubuntu18.04系统

    2. 更新系统

      sudo apt update
      sudo apt upgrade
      
    3. 安装vim

      sudo apt install vim
      
    4. 安装git

      sudo apt install git
      
    5. 创建git仓库

      # 创建git用户
      sudo adduser git
      
      # 切换到git用户
      su git
      
      # 进入git用户目录
      cd ~
      
    6. 安装gitolite

      git clone https://github.com/sitaramc/gitolite
      
      mkdir -p $HOME/bin
      
      gitolite/install -to $HOME/bin
      
    7. 注册仓库管理员

      新建YourName.pub文件,将客户端公钥.ssh/id_rsa.pub复制到里面,然后注册为仓库管理员

      vim YourName.pub                           # 复制客户端公钥内容,按:wq保存退出
      
      $HOME/bin/gitolite setup -pk YourName.pub  # 注册仓库管理员
      

      也可以在服务器上新建admin用户作为仓库管理员,方便管理

      # 新建管理员用户admin
      sudo adduser admin
      
      # 生成SSH公钥
      su admin
      ssh-keygen -t rsa -C "youremail@example.com"
      cp .ssh/id_rsa.pub /tmp/admin.pub
      
      # 切换回git用户,将admin用户注册为仓库管理员
      su git
      cd ~
      $HOME/bin/gitolite setup -pk /tmp/admin.pub
      

      注册管理员后会生成两个文件projects.list, repositories/

      • projects.list保存仓库信息列表

      • repositories/文件夹里有管理员仓库gitolite-admin.git/和测试仓库testing.git/

      • 新建的仓库都会保存在repositories/文件中

    8. 管理远程仓库

      在已经注册过的客户端克隆管理员仓库

      git clone git@host:gitolite-admin
      

      管理员仓库里有两个文件conf/gitolite.confkeydir/

      • gitolite.conf管理仓库信息

      • keydir/保存git成员的公钥

      添加新成员: 将新成员的公钥保存到keydir/

      新建仓库: 修改conf/gitolite.conf文件,添加newrepo仓库

      repo gitolite-admin
           RW+     =   admin
      
      repo testing
           RW+     =   @all
      
      repo newrepo
           RW+     =   @all
      

      添加仓库管理员username

      repo gitolite-admin
           RW+     =   admin
           RW+     =   username
      
      repo testing
           RW+     =   @all
      
      repo newrepo
           RW+     =   @all
      
    9. 将仓库信息推送到服务器

      在客户端更新完仓库信息后,需要将其推送到服务器才能生效

      git add .
      git commit -m "commit message"
      git push origin master
      

    参考

    sitaramc/gitolite

  • 相关阅读:
    Understanding about Baire Category Theorem
    Isometric embedding of metric space
    Convergence theorems for measurable functions
    Mindmap for "Principles of boundary element methods"
    Various formulations of Maxwell equations
    Existence and uniqueness theorems for variational problems
    Kernels and image sets for an operator and its dual
    [loj6498]农民
    [luogu3781]切树游戏
    [atAGC051B]Three Coins
  • 原文地址:https://www.cnblogs.com/lin-zone/p/10991191.html
Copyright © 2011-2022 走看看